BaseDexClassLoader
public
class
BaseDexClassLoader
extends ClassLoader
Known Direct Subclasses
DexClassLoader |
A class loader that loads classes from .jar and .apk files
containing a classes.dex entry.
|
PathClassLoader |
Provides a simple ClassLoader implementation that operates on a list
of files and directories in the local file system, but does not attempt to
load classes from the network.
|
|
Base class for common functionality between various dex-based
ClassLoader
implementations.
Summary
Inherited methods |
From
class
java.lang.ClassLoader
void
|
clearAssertionStatus()
Sets the default assertion status for this class loader to
false and discards any package defaults or class assertion
status settings associated with the class loader.
|
final
Class<?>
|
defineClass(String name, byte[] b, int off, int len, ProtectionDomain protectionDomain)
Converts an array of bytes into an instance of class Class,
with an optional ProtectionDomain.
|
final
Class<?>
|
defineClass(String name, ByteBuffer b, ProtectionDomain protectionDomain)
Converts a ByteBuffer
into an instance of class Class,
with an optional ProtectionDomain.
|
final
Class<?>
|
defineClass(byte[] b, int off, int len)
This method was deprecated
in API level 1.
Replaced by defineClass(String, byte[], int, int)
|
final
Class<?>
|
defineClass(String name, byte[] b, int off, int len)
Converts an array of bytes into an instance of class Class.
|
Package
|
definePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase)
Defines a package by name in this ClassLoader.
|
Class<?>
|
findClass(String name)
Finds the class with the specified binary name.
|
String
|
findLibrary(String libname)
Returns the absolute path name of a native library.
|
final
Class<?>
|
findLoadedClass(String name)
Returns the class with the given binary name if this
loader has been recorded by the Java virtual machine as an initiating
loader of a class with that binary name.
|
URL
|
findResource(String name)
Finds the resource with the given name.
|
Enumeration<URL>
|
findResources(String name)
Returns an enumeration of URL objects
representing all the resources with the given name.
|
final
Class<?>
|
findSystemClass(String name)
Finds a class with the specified binary name,
loading it if necessary.
|
Package
|
getPackage(String name)
Returns a Package that has been defined by this class loader
or any of its ancestors.
|
Package[]
|
getPackages()
Returns all of the Packages defined by this class loader and
its ancestors.
|
final
ClassLoader
|
getParent()
Returns the parent class loader for delegation.
|
URL
|
getResource(String name)
Finds the resource with the given name.
|
InputStream
|
getResourceAsStream(String name)
Returns an input stream for reading the specified resource.
|
Enumeration<URL>
|
getResources(String name)
Finds all the resources with the given name.
|
static
ClassLoader
|
getSystemClassLoader()
Returns the system class loader for delegation.
|
static
URL
|
getSystemResource(String name)
Find a resource of the specified name from the search path used to load
classes.
|
static
InputStream
|
getSystemResourceAsStream(String name)
Open for reading, a resource of the specified name from the search path
used to load classes.
|
static
Enumeration<URL>
|
getSystemResources(String name)
Finds all resources of the specified name from the search path used to
load classes.
|
Class<?>
|
loadClass(String name, boolean resolve)
Loads the class with the specified binary name.
|
Class<?>
|
loadClass(String name)
Loads the class with the specified binary name.
|
static
boolean
|
registerAsParallelCapable()
Registers the caller as parallel capable.
|
final
void
|
resolveClass(Class<?> c)
Links the specified class.
|
void
|
setClassAssertionStatus(String className, boolean enabled)
Sets the desired assertion status for the named top-level class in this
class loader and any nested classes contained therein.
|
void
|
setDefaultAssertionStatus(boolean enabled)
Sets the default assertion status for this class loader.
|
void
|
setPackageAssertionStatus(String packageName, boolean enabled)
Sets the package default assertion status for the named package.
|
final
void
|
setSigners(Class<?> c, Object[] signers)
Sets the signers of a class.
|
|
From
class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long millis, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long millis)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
|
Public constructors
BaseDexClassLoader
BaseDexClassLoader (String dexPath,
File optimizedDirectory,
String librarySearchPath,
ClassLoader parent)
Constructs an instance.
Parameters |
dexPath |
String :
the list of jar/apk files containing classes and
resources, delimited by File.pathSeparator , which
defaults to ":" on Android |
optimizedDirectory |
File :
directory where optimized dex files
should be written; may be null |
librarySearchPath |
String :
the list of directories containing native
libraries, delimited by File.pathSeparator ; may be
null |
parent |
ClassLoader :
the parent class loader
|
Public methods
findLibrary
String findLibrary (String name)
Returns the absolute path name of a native library. The VM invokes this
method to locate the native libraries that belong to classes loaded with
this class loader. If this method returns null, the VM
searches the library along the path specified as the
"java.library.path" property.
Parameters |
name |
String :
The library name |
Returns |
String |
The absolute path of the native library |
toString
String toString ()
Returns a string representation of the object. In general, the
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Returns |
String |
a string representation of the object.
|
Protected methods
findClass
Class<?> findClass (String name)
Finds the class with the specified binary name.
This method should be overridden by class loader implementations that
follow the delegation model for loading classes, and will be invoked by
the loadClass
method after checking the
parent class loader for the requested class. The default implementation
throws a ClassNotFoundException.
Returns |
Class<?> |
The resulting Class object |
findResource
URL findResource (String name)
Finds the resource with the given name. Class loader implementations
should override this method to specify where to find resources.
Parameters |
name |
String :
The resource name |
Returns |
URL |
A URL object for reading the resource, or
null if the resource could not be found |
findResources
Enumeration<URL> findResources (String name)
Returns an enumeration of URL
objects
representing all the resources with the given name. Class loader
implementations should override this method to specify where to load
resources from.
Parameters |
name |
String :
The resource name |
getPackage
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.
Parameters |
name |
String :
the name of the class |
Returns |
Package |
the package information for the class, or null
if there is no package information available for it
|