Package dalvik.system

Class BaseDexClassLoader

    • Constructor Detail

      • BaseDexClassLoader

        public BaseDexClassLoader​(String dexPath,
                                  File optimizedDirectory,
                                  String libraryPath,
                                  ClassLoader parent)
        Constructs an instance.
        Parameters:
        dexPath - the list of jar/apk files containing classes and resources, delimited by File.pathSeparator, which defaults to ":" on Android
        optimizedDirectory - directory where optimized dex files should be written; may be null
        libraryPath - the list of directories containing native libraries, delimited by File.pathSeparator; may be null
        parent - the parent class loader
    • Method Detail

      • findClass

        protected Class<?> findClass​(String name)
                              throws ClassNotFoundException
        Description copied from class: ClassLoader
        Overridden by subclasses, throws a ClassNotFoundException by default. This method is called by loadClass after the parent ClassLoader has failed to find a loaded class of the same name.
        Overrides:
        findClass in class ClassLoader
        Parameters:
        name - the name of the class to look for.
        Returns:
        the Class object that is found.
        Throws:
        ClassNotFoundException - if the class cannot be found.
      • findResource

        protected URL findResource​(String name)
        Description copied from class: ClassLoader
        Finds the URL of the resource with the specified name. This implementation just returns null; it should be overridden in subclasses.
        Overrides:
        findResource in class ClassLoader
        Parameters:
        name - the name of the resource to find.
        Returns:
        the URL object for the requested resource.
      • findResources

        protected Enumeration<URL> findResources​(String name)
        Description copied from class: ClassLoader
        Finds an enumeration of URLs for the resource with the specified name. This implementation just returns an empty Enumeration; it should be overridden in subclasses.
        Overrides:
        findResources in class ClassLoader
        Parameters:
        name - the name of the resource to find.
        Returns:
        an enumeration of URL objects for the requested resource.
      • findLibrary

        public String findLibrary​(String name)
        Description copied from class: ClassLoader
        Returns the absolute path of the native library with the specified name, or null. If this method returns null then the virtual machine searches the directories specified by the system property "java.library.path".

        This implementation always returns null.

        Overrides:
        findLibrary in class ClassLoader
        Parameters:
        name - the name of the library to find.
        Returns:
        the absolute path of the library.
      • getPackage

        protected Package getPackage​(String name)
        Returns package information for the given package. Unfortunately, instances of this class don't really have this information, and as a non-secure ClassLoader, it isn't even required to, according to the spec. Yet, we want to provide it, in order to make all those hopeful callers of myClass.getPackage().getName() happy. Thus we construct a Package object the first time it is being requested and fill most of the fields with dummy values. The Package object is then put into the ClassLoader's package cache, so we see the same one next time. We don't create Package objects for null arguments or for the default package.

        There is a limited chance that we end up with multiple Package objects representing the same package: It can happen when when a package is scattered across different JAR files which were loaded by different ClassLoader instances. This is rather unlikely, and given that this whole thing is more or less a workaround, probably not worth the effort to address.

        Overrides:
        getPackage in class ClassLoader
        Parameters:
        name - the name of the class
        Returns:
        the package information for the class, or null if there is no package information available for it
      • getLdLibraryPath

        public String getLdLibraryPath()
      • toString

        public String toString()
        Description copied from class: Object
        Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
           getClass().getName() + '@' + Integer.toHexString(hashCode())

        See Writing a useful toString method if you intend implementing your own toString method.

        Overrides:
        toString in class Object
        Returns:
        a printable representation of this object.