| Modifier and Type | Field and Description |
|---|---|
static int |
DEX2OAT_NEEDED
|
static int |
NO_DEXOPT_NEEDED
|
static int |
PATCHOAT_NEEDED
|
static int |
SELF_PATCHOAT_NEEDED
|
| Constructor and Description |
|---|
DexFile(File file)
Opens a DEX file from a given File object.
|
DexFile(String fileName)
Opens a DEX file from a given filename.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the DEX file.
|
Enumeration<String> |
entries()
Enumerate the names of the classes in this DEX file.
|
protected void |
finalize()
Called when the class is finalized.
|
static int |
getDexOptNeeded(String fileName,
String pkgname,
String instructionSet,
boolean defer)
Returns the VM's opinion of what kind of dexopt is needed to make the
apk/jar file up to date.
|
String |
getName()
Gets the name of the (already opened) DEX file.
|
static boolean |
isDexOptNeeded(String fileName)
Returns true if the VM believes that the apk/jar file is out of date
and should be passed through "dexopt" again.
|
Class |
loadClass(String name,
ClassLoader loader)
Loads a class.
|
Class |
loadClassBinaryName(String name,
ClassLoader loader,
List<Throwable> suppressed)
|
static DexFile |
loadDex(String sourcePathName,
String outputPathName,
int flags)
Open a DEX file, specifying the file in which the optimized DEX
data should be written.
|
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
public static final int NO_DEXOPT_NEEDED
public static final int DEX2OAT_NEEDED
public static final int PATCHOAT_NEEDED
public static final int SELF_PATCHOAT_NEEDED
public DexFile(File file) throws IOException
file - the File object referencing the actual DEX fileIOException - if an I/O error occurs, such as the file not being found or
access rights missing for opening itpublic DexFile(String fileName) throws IOException
fileName - the filename of the DEX fileIOException - if an I/O error occurs, such as the file not being found or
access rights missing for opening itpublic static DexFile loadDex(String sourcePathName, String outputPathName, int flags) throws IOException
sourcePathName - Jar or APK file with "classes.dex". (May expand this to include
"raw DEX" in the future.)outputPathName - File that will hold the optimized form of the DEX data.flags - Enable optional features. (Currently none defined.)IOException - If unable to open the source or output file.public String getName()
public String toString()
ObjectgetClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString method
if you intend implementing your own toString method.
public void close()
throws IOException
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.
IOException - if an I/O error occurs during closing the file, which
normally should not happenpublic Class loadClass(String name, ClassLoader loader)
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.
name - the class name, which should look like "java/lang/String"loader - the class loader that tries to load the class (in most cases
the caller of the methodClass object representing the class, or null
if the class cannot be loadedpublic Class loadClassBinaryName(String name, ClassLoader loader, List<Throwable> suppressed)
loadClass(String, ClassLoader).
This takes a "binary" class name to better match ClassLoader semantics.public Enumeration<String> entries()
protected void finalize()
throws Throwable
finalize in class ObjectIOException - if an I/O error occurs during closing the file, which
normally should not happenThrowablepublic static boolean isDexOptNeeded(String fileName) throws FileNotFoundException, IOException
fileName - the absolute path to the apk/jar file to examine.FileNotFoundException - if fileName is not readable,
not a file, or not present.IOException - if fileName is not a valid apk/jar file or
if problems occur while parsing it.NullPointerException - if fileName is null.public static int getDexOptNeeded(String fileName, String pkgname, String instructionSet, boolean defer) throws FileNotFoundException, IOException
fileName - the absolute path to the apk/jar file to examine.FileNotFoundException - if fileName is not readable,
not a file, or not present.IOException - if fileName is not a valid apk/jar file or
if problems occur while parsing it.NullPointerException - if fileName is null.