Class SandboxClassLoader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class SandboxClassLoader
    extends java.net.URLClassLoader
    Class loader that modifies the bytecode of Android classes to insert calls to Robolectric's shadow classes.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected byte[] getByteCode​(java.lang.String className)  
      java.net.URL getResource​(java.lang.String name)  
      java.lang.Class<?> loadClass​(java.lang.String name, boolean resolve)  
      protected java.lang.Class<?> maybeInstrumentClass​(java.lang.String className)  
      protected byte[] postProcessUninstrumentedClass​(MutableClass mutableClass, byte[] origClassBytes)  
      • Methods inherited from class java.net.URLClassLoader

        addURL, close, 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getResource

        public java.net.URL getResource​(java.lang.String name)
        Overrides:
        getResource in class java.lang.ClassLoader
      • loadClass

        public java.lang.Class<?> loadClass​(java.lang.String name,
                                            boolean resolve)
                                     throws java.lang.ClassNotFoundException
        Overrides:
        loadClass in class java.lang.ClassLoader
        Throws:
        java.lang.ClassNotFoundException
      • maybeInstrumentClass

        protected java.lang.Class<?> maybeInstrumentClass​(java.lang.String className)
                                                   throws java.lang.ClassNotFoundException
        Throws:
        java.lang.ClassNotFoundException
      • postProcessUninstrumentedClass

        protected byte[] postProcessUninstrumentedClass​(MutableClass mutableClass,
                                                        byte[] origClassBytes)
      • getByteCode

        protected byte[] getByteCode​(java.lang.String className)
                              throws java.lang.ClassNotFoundException
        Throws:
        java.lang.ClassNotFoundException