Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

BaseDexClassLoader

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

Class Overview

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.
synchronized Package getPackage ( String name)
Returns package information for the given package.
[Expand]
Inherited Methods
From class java.lang.ClassLoader
From class java.lang.Object

Public Constructors

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

Public Methods

public String findLibrary ( String name)

Added in API level 1

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 the name of the library to find.
Returns
  • the absolute path of the library.

public String toString ()

Added in API level 1

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
  • a printable representation of this object.

Protected Methods

protected Class <?> findClass ( String name)

Added in API level 1

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 the name of the class to look for.
Returns
  • the Class object that is found.

protected URL findResource ( String name)

Added in API level 1

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

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

protected Enumeration < URL > findResources ( String name)

Added in API level 1

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 the name of the resource to find.
Returns
  • an enumeration of URL objects for the requested resource.

protected synchronized Package getPackage ( String name)

Added in API level 1

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 the name of the class
Returns
  • the package information for the class, or null if there is no package information available for it