Skip to content

Most visited

Recently visited

navigation
Added in API level 14

BaseDexClassLoader

public class BaseDexClassLoader
extends ClassLoader

java.lang.Object
   ↳ java.lang.ClassLoader
     ↳ dalvik.system.BaseDexClassLoader
Known Direct Subclasses


Base class for common functionality between various dex-based ClassLoader implementations.

Summary

Public constructors

BaseDexClassLoader(String dexPath, File optimizedDirectory, String libraryPath, ClassLoader parent)

Constructs an instance.

Public methods

String findLibrary(String name)

Returns the absolute path of the native library with the specified name, or null.

String toString()

Returns a string containing a concise, human-readable description of this object.

Protected methods

Class<?> findClass(String name)

Overridden by subclasses, throws a ClassNotFoundException by default.

URL findResource(String name)

Finds the URL of the resource with the specified name.

Enumeration<URL> findResources(String name)

Finds an enumeration of URLs for the resource with the specified name.

Package getPackage(String name)

Returns package information for the given package.

Inherited methods

From class java.lang.ClassLoader
From class java.lang.Object

Public constructors

BaseDexClassLoader

Added in API level 14
BaseDexClassLoader (String dexPath, 
                File optimizedDirectory, 
                String libraryPath, 
                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
libraryPath String: the list of directories containing native libraries, delimited by File.pathSeparator; may be null
parent ClassLoader: the parent class loader

Public methods

findLibrary

Added in API level 1
String findLibrary (String name)

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.

Parameters
name String: the name of the library to find.
Returns
String the absolute path of the library.

toString

Added in API level 1
String toString ()

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.

Returns
String a printable representation of this object.

Protected methods

findClass

Added in API level 1
Class<?> findClass (String name)

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.

Parameters
name String: the name of the class to look for.
Returns
Class<?> the Class object that is found.
Throws
ClassNotFoundException

findResource

Added in API level 1
URL findResource (String name)

Finds the URL of the resource with the specified name. This implementation just returns null; it should be overridden in subclasses.

Parameters
name String: the name of the resource to find.
Returns
URL the URL object for the requested resource.

findResources

Added in API level 1
Enumeration<URL> findResources (String name)

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.

Parameters
name String: the name of the resource to find.
Returns
Enumeration<URL> an enumeration of URL objects for the requested resource.

getPackage

Added in API level 1
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
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.