public class BaseDexClassLoader extends ClassLoader
ClassLoader implementations.proxyCache| Constructor and Description |
|---|
BaseDexClassLoader(String dexPath,
File optimizedDirectory,
String libraryPath,
ClassLoader parent)
Constructs an instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected Class<?> |
findClass(String name)
Overridden by subclasses, throws a
ClassNotFoundException by
default. |
String |
findLibrary(String name)
Returns the absolute path of the native library with the specified name,
or
null. |
protected URL |
findResource(String name)
Finds the URL of the resource with the specified name.
|
protected Enumeration<URL> |
findResources(String name)
Finds an enumeration of URLs for the resource with the specified name.
|
String |
getLdLibraryPath() |
protected Package |
getPackage(String name)
Returns package information for the given package.
|
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSignerspublic BaseDexClassLoader(String dexPath, File optimizedDirectory, String libraryPath, ClassLoader parent)
dexPath - the list of jar/apk files containing classes and
resources, delimited by File.pathSeparator, which
defaults to ":" on AndroidoptimizedDirectory - directory where optimized dex files
should be written; may be nulllibraryPath - the list of directories containing native
libraries, delimited by File.pathSeparator; may be
nullparent - the parent class loaderprotected Class<?> findClass(String name) throws ClassNotFoundException
ClassLoaderClassNotFoundException by
default. This method is called by loadClass after the parent
ClassLoader has failed to find a loaded class of the same name.findClass in class ClassLoadername - the name of the class to look for.Class object that is found.ClassNotFoundException - if the class cannot be found.protected URL findResource(String name)
ClassLoadernull; it should be overridden in
subclasses.findResource in class ClassLoadername - the name of the resource to find.URL object for the requested resource.protected Enumeration<URL> findResources(String name)
ClassLoaderEnumeration; it should
be overridden in subclasses.findResources in class ClassLoadername - the name of the resource to find.URL objects for the requested resource.public String findLibrary(String name)
ClassLoadernull. 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.
findLibrary in class ClassLoadername - the name of the library to find.protected Package getPackage(String name)
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.
getPackage in class ClassLoadername - the name of the classnull
if there is no package information available for itpublic String getLdLibraryPath()
public String toString()
ObjectgetClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString method
if you intend implementing your own toString method.