Added in API level 14

BaseDexClassLoader

open class BaseDexClassLoader : ClassLoader
kotlin.Any
   ↳ java.lang.ClassLoader
   ↳ dalvik.system.BaseDexClassLoader

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

Summary

Public constructors
BaseDexClassLoader(dexPath: String!, optimizedDirectory: File!, librarySearchPath: String!, parent: ClassLoader!)

Constructs an instance.

Public methods
open String!

open String

Protected methods
open Class<*>!
findClass(name: String!)

open URL!

open Enumeration<URL!>!

open Package!

Returns package information for the given package.

Inherited functions

Public constructors

BaseDexClassLoader

Added in API level 14
BaseDexClassLoader(
    dexPath: String!,
    optimizedDirectory: File!,
    librarySearchPath: String!,
    parent: ClassLoader!)

Constructs an instance. Note that all the *.jar and *.apk files from dexPath might be first extracted in-memory before the code is loaded. This can be avoided by passing raw dex files (*.dex) in the dexPath.

Parameters
dexPath String!: the list of jar/apk files containing classes and resources, delimited by File.pathSeparator, which defaults to ":" on Android.
optimizedDirectory File!: this parameter is deprecated and has no effect since API level 26.
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

Added in API level 14
open fun findLibrary(name: String!): String!
Parameters
libname The library name
Return
String! The absolute path of the native library

toString

Added in API level 14
open fun toString(): String
Return
String a string representation of the object.

Protected methods

findClass

Added in API level 14
protected open fun findClass(name: String!): Class<*>!
Parameters
name String!: The binary name of the class
Return
Class<*>! The resulting Class object
Exceptions
java.lang.ClassNotFoundException If the class could not be found

findResource

Added in API level 14
protected open fun findResource(name: String!): URL!
Parameters
name String!: The resource name
Return
URL! URL object for reading the resource; null if the resource could not be found, a URL could not be constructed to locate the resource, the resource is in a package that is not opened unconditionally, or access to the resource is denied by the security manager.

findResources

Added in API level 14
protected open fun findResources(name: String!): Enumeration<URL!>!
Parameters
name String!: The resource name
Return
Enumeration<URL!>! An enumeration of URL objects for the resource. If no resources could be found, the enumeration will be empty. Resources for which a URL cannot be constructed, are in a package that is not opened unconditionally, or access to the resource is denied by the security manager, are not returned in the enumeration.
Exceptions
java.io.IOException If I/O errors occur

getPackage

Added in API level 14
protected open fun getPackage(name: String!): Package!

Deprecated: See ClassLoader.getPackage(String)

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 fake 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
Return
Package! the package information for the class, or null if there is no package information available for it
Exceptions
java.lang.NullPointerException if name is null.