Class SandboxClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.robolectric.internal.bytecode.SandboxClassLoader
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
AndroidSandbox.SdkSandboxClassLoader
Class loader that modifies the bytecode of Android classes to insert calls to Robolectric's
shadow classes.
-
Constructor Summary
ConstructorDescriptionSandboxClassLoader
(ClassLoader erstwhileClassLoader, InstrumentationConfiguration config, ResourceProvider resourceProvider, ClassInstrumentor classInstrumentor) SandboxClassLoader
(InstrumentationConfiguration config, ResourceProvider resourceProvider, ClassInstrumentor classInstrumentor) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected byte[]
getByteCode
(String className) getResource
(String name) Class<?>
protected Class<?>
maybeInstrumentClass
(String className) protected byte[]
postProcessUninstrumentedClass
(ClassDetails classDetails) Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
Methods 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
-
SandboxClassLoader
@Inject public SandboxClassLoader(InstrumentationConfiguration config, ResourceProvider resourceProvider, ClassInstrumentor classInstrumentor) -
SandboxClassLoader
public SandboxClassLoader(ClassLoader erstwhileClassLoader, InstrumentationConfiguration config, ResourceProvider resourceProvider, ClassInstrumentor classInstrumentor)
-
-
Method Details
-
getResource
- Overrides:
getResource
in classClassLoader
-
loadClass
- Overrides:
loadClass
in classClassLoader
- Throws:
ClassNotFoundException
-
maybeInstrumentClass
- Throws:
ClassNotFoundException
-
postProcessUninstrumentedClass
-
getByteCode
- Throws:
ClassNotFoundException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classURLClassLoader
- Throws:
IOException
-