Package dalvik.system
Class BaseDexClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- dalvik.system.BaseDexClassLoader
-
- Direct Known Subclasses:
DexClassLoader,PathClassLoader
public class BaseDexClassLoader extends ClassLoader
Base class for common functionality between various dex-basedClassLoaderimplementations.
-
-
Field Summary
-
Fields inherited from class java.lang.ClassLoader
proxyCache
-
-
Constructor Summary
Constructors Constructor Description BaseDexClassLoader(String dexPath, File optimizedDirectory, String libraryPath, ClassLoader parent)Constructs an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Class<?>findClass(String name)Overridden by subclasses, throws aClassNotFoundExceptionby default.StringfindLibrary(String name)Returns the absolute path of the native library with the specified name, ornull.protected URLfindResource(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.StringgetLdLibraryPath()protected PackagegetPackage(String name)Returns package information for the given package.StringtoString()Returns a string containing a concise, human-readable description of this object.-
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
-
-
-
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 byFile.pathSeparator, which defaults to":"on AndroidoptimizedDirectory- directory where optimized dex files should be written; may benulllibraryPath- the list of directories containing native libraries, delimited byFile.pathSeparator; may benullparent- the parent class loader
-
-
Method Detail
-
findClass
protected Class<?> findClass(String name) throws ClassNotFoundException
Description copied from class:ClassLoaderOverridden by subclasses, throws aClassNotFoundExceptionby default. This method is called byloadClassafter the parentClassLoaderhas failed to find a loaded class of the same name.- Overrides:
findClassin classClassLoader- Parameters:
name- the name of the class to look for.- Returns:
- the
Classobject that is found. - Throws:
ClassNotFoundException- if the class cannot be found.
-
findResource
protected URL findResource(String name)
Description copied from class:ClassLoaderFinds the URL of the resource with the specified name. This implementation just returnsnull; it should be overridden in subclasses.- Overrides:
findResourcein classClassLoader- Parameters:
name- the name of the resource to find.- Returns:
- the
URLobject for the requested resource.
-
findResources
protected Enumeration<URL> findResources(String name)
Description copied from class:ClassLoaderFinds an enumeration of URLs for the resource with the specified name. This implementation just returns an emptyEnumeration; it should be overridden in subclasses.- Overrides:
findResourcesin classClassLoader- Parameters:
name- the name of the resource to find.- Returns:
- an enumeration of
URLobjects for the requested resource.
-
findLibrary
public String findLibrary(String name)
Description copied from class:ClassLoaderReturns the absolute path of the native library with the specified name, ornull. If this method returnsnullthen the virtual machine searches the directories specified by the system property "java.library.path".This implementation always returns
null.- Overrides:
findLibraryin classClassLoader- 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-secureClassLoader, it isn't even required to, according to the spec. Yet, we want to provide it, in order to make all those hopeful callers ofmyClass.getPackage().getName()happy. Thus we construct aPackageobject the first time it is being requested and fill most of the fields with dummy values. ThePackageobject is then put into theClassLoader's package cache, so we see the same one next time. We don't createPackageobjects fornullarguments or for the default package.There is a limited chance that we end up with multiple
Packageobjects representing the same package: It can happen when when a package is scattered across different JAR files which were loaded by differentClassLoaderinstances. This is rather unlikely, and given that this whole thing is more or less a workaround, probably not worth the effort to address.- Overrides:
getPackagein classClassLoader- Parameters:
name- the name of the class- Returns:
- the package information for the class, or
nullif there is no package information available for it
-
getLdLibraryPath
public String getLdLibraryPath()
-
toString
public String toString()
Description copied from class:ObjectReturns 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
toStringmethod if you intend implementing your owntoStringmethod.
-
-