Package org.robolectric.simulator
Class SimulatorClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.robolectric.internal.bytecode.SandboxClassLoader
org.robolectric.internal.AndroidSandbox.SdkSandboxClassLoader
org.robolectric.simulator.SimulatorClassLoader
- All Implemented Interfaces:
Closeable,AutoCloseable,ClassTracker
@AutoService(SdkSandboxClassLoader.class)
public class SimulatorClassLoader
extends AndroidSandbox.SdkSandboxClassLoader
An override of
AndroidSandbox.SdkSandboxClassLoader that supports extra local Jars in the
classpath.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEncapsulates a collection of Jar files. -
Constructor Summary
ConstructorsConstructorDescriptionSimulatorClassLoader(InstrumentationConfiguration config, Sdk runtimeSdk, ClassInstrumentor classInstrumentor, SimulatorClassLoader.JarCollection jarCollection) -
Method Summary
Modifier and TypeMethodDescriptionfindResources(String name) This override is required to support ServiceLoader plugins in the extra jars passed into the simulator.protected InputStreamgetClassBytesFromAlternateClassLoader(String classResName) This allows the simulator to provide classes from the deploy jar before classes from the runtime classpath.protected URLgetResourceUrl(String name) Methods inherited from class org.robolectric.internal.bytecode.SandboxClassLoader
close, getResource, isClassLoaded, loadClassMethods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class java.security.SecureClassLoader
defineClass, defineClassMethods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
SimulatorClassLoader
public SimulatorClassLoader(InstrumentationConfiguration config, @Named("runtimeSdk") Sdk runtimeSdk, ClassInstrumentor classInstrumentor, SimulatorClassLoader.JarCollection jarCollection)
-
-
Method Details
-
getClassBytesFromAlternateClassLoader
This allows the simulator to provide classes from the deploy jar before classes from the runtime classpath.The order of preference is:
- The Android framework jars
- The extra jars managed by the simulator (deploy jar and extra jars passed as args)
- The jars that are on the runtime classpath.
- Overrides:
getClassBytesFromAlternateClassLoaderin classSandboxClassLoader
-
findResources
This override is required to support ServiceLoader plugins in the extra jars passed into the simulator. It looks for all service-related metadata in META-INF/services/... in the extra jars before falling back to the superclass implementation.- Overrides:
findResourcesin classURLClassLoader- Throws:
IOException
-
getResourceUrl
- Overrides:
getResourceUrlin classSandboxClassLoader
-