DexFile
class DexFile
kotlin.Any | |
↳ | dalvik.system.DexFile |
Loads DEX files. This class is meant for internal use and should not be used by applications. Applications should not instantiate this class. It will hurt performance in most cases and will lead to incorrect execution of bytecode in the worst case. Applications should use one of the standard classloaders such as dalvik.system.PathClassLoader
instead. Non-static APIs will be removed in a future Android release.
Summary
Nested classes | |
---|---|
Encapsulates information about the optimizations performed on a dex file. |
Public constructors | |
---|---|
Opens a DEX file from a given File object. |
|
Opens a DEX file from a given filename. |
Public methods | |
---|---|
Unit |
close() Closes the DEX file. |
Enumeration<String!>! |
entries() Enumerate the names of the classes in this DEX file. |
String! |
getName() Gets the name of the (already opened) DEX file. |
static Boolean |
isDexOptNeeded(fileName: String!) Returns true if the VM believes that the apk/jar file is out of date and should be passed through "dexopt" again. |
Class<Any!>! |
loadClass(name: String!, loader: ClassLoader!) Loads a class. |
static DexFile! |
Open a DEX file, specifying the file in which the optimized DEX data should be written. |
String |
toString() |
Protected methods | |
---|---|
Unit |
finalize() Called when the class is finalized. |
Public constructors
DexFile
DexFile(file: File!)
Deprecated: Applications should use one of the standard classloaders such as dalvik.system.PathClassLoader
instead. This API will be removed in a future Android release.
Opens a DEX file from a given File object.
DexFile
DexFile(fileName: String!)
Deprecated: Applications should use one of the standard classloaders such as dalvik.system.PathClassLoader
instead. This API will be removed in a future Android release.
Opens a DEX file from a given filename.
Public methods
close
funclose(): Unit
Deprecated: Applications should use one of the standard classloaders such as dalvik.system.PathClassLoader
instead. This API will be removed in a future Android release.
Closes the DEX file.
This may not be able to release all of the resources. If classes from this DEX file are still resident, the DEX file can't be unmapped. In the case where we do not release all the resources, close is called again in the finalizer.
Exceptions | |
---|---|
java.io.IOException |
if an I/O error occurs during closing the file, which normally should not happen |
entries
funentries(): Enumeration<String!>!
Deprecated: Applications should use one of the standard classloaders such as dalvik.system.PathClassLoader
instead. This API will be removed in a future Android release.
Enumerate the names of the classes in this DEX file.
Return | |
---|---|
Enumeration<String!>! |
an enumeration of names of classes contained in the DEX file, in the usual internal form (like "java/lang/String"). |
getName
fungetName(): String!
Deprecated: Applications should use one of the standard classloaders such as dalvik.system.PathClassLoader
instead. This API will be removed in a future Android release.
Gets the name of the (already opened) DEX file.
Return | |
---|---|
String! |
the file name |
isDexOptNeeded
static funisDexOptNeeded(fileName: String!): Boolean
Deprecated: Use Artd.getDexoptNeeded
instead.
Returns true if the VM believes that the apk/jar file is out of date and should be passed through "dexopt" again.
Parameters | |
---|---|
fileName |
String!: the absolute path to the apk/jar file to examine. |
Return | |
---|---|
Boolean |
true if dexopt should be called on the file, false otherwise. |
Exceptions | |
---|---|
java.io.FileNotFoundException |
if fileName is not readable, not a file, or not present. |
java.io.IOException |
if fileName is not a valid apk/jar file or if problems occur while parsing it. |
java.lang.NullPointerException |
if fileName is null. |
loadClass
funloadClass(
name: String!,
loader: ClassLoader!
): Class<Any!>!
Deprecated: Applications should use one of the standard classloaders such as dalvik.system.PathClassLoader
instead. This API will be removed in a future Android release.
Loads a class. Returns the class on success, or a null
reference on failure.
If you are not calling this from a class loader, this is most likely not going to do what you want. Use Class.forName(String)
instead.
The method does not throw ClassNotFoundException
if the class isn't found because it isn't reasonable to throw exceptions wildly every time a class is not found in the first DEX file we look at.
Parameters | |
---|---|
name |
String!: the class name, which should look like "java/lang/String" |
loader |
ClassLoader!: the class loader that tries to load the class (in most cases the caller of the method |
Return | |
---|---|
Class<Any!>! |
the Class object representing the class, or null if the class cannot be loaded |
loadDex
static funloadDex(
sourcePathName: String!,
outputPathName: String!,
flags: Int
): DexFile!
Deprecated: Applications should use one of the standard classloaders such as dalvik.system.PathClassLoader
instead. This API will be removed in a future Android release.
Open a DEX file, specifying the file in which the optimized DEX data should be written. If the optimized form exists and appears to be current, it will be used; if not, the VM will attempt to regenerate it.
toString
fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |
Protected methods
finalize
protected fun finalize(): Unit
Called when the class is finalized. Makes sure the DEX file is closed.
Exceptions | |
---|---|
java.lang.Throwable |
the Exception raised by this method |
java.io.IOException |
if an I/O error occurs during closing the file, which normally should not happen |