android 开发dex文件,DexFile  |  Android 开发者  |  Android Developers

DexFile

public

final

class

DexFile

extends Object↳

dalvik.system.DexFile

This class was deprecated

in API level 26.

This class should not be used directly by applications. 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 This API will be removed

in a future Android release.

Loads DEX files. This class is meant for internal use and should not be used

by applications.

Summary

Public constructors

This constructor is deprecated.

Applications should use one of the standard classloaders such

as This API will be removed

in a future Android release.

This constructor is deprecated.

Applications should use one of the standard classloaders such

as This API will be removed

in a future Android release.

Public methods

void

Closes the DEX file.

Enumerate the names of the classes in this DEX file.

Gets the name of the (already opened) DEX file.

static

boolean

Returns true if the VM believes that the apk/jar file is out of date

and should be passed through "dexopt" again.

loadDex(String sourcePathName, String outputPathName, int flags)

This method was deprecated

in API level 26.

Applications should use one of the standard classloaders such

as This API will be removed

in a future Android release.

Returns a string representation of the object.

Protected methods

void

Called when the class is finalized.

Inherited methods

Creates and returns a copy of this object.

boolean

Indicates whether some other object is "equal to" this one.

void

Called by the garbage collector on an object when garbage collection

determines that there are no more references to the object.

final

Class>

Returns the runtime class of this Object.

int

Returns a hash code value for the object.

final

void

Wakes up a single thread that is waiting on this object's

monitor.

final

void

Wakes up all threads that are waiting on this object's monitor.

Returns a string representation of the object.

final

void

wait(long timeout, int nanos)

Causes the current thread to wait until another thread invokes the

final

void

wait(long timeout)

Causes the current thread to wait until either another thread invokes the

final

void

Causes the current thread to wait until another thread invokes the

Public constructors

DexFile

public DexFile (File file)

This constructor is deprecated.

Applications should use one of the standard classloaders such

as This API will be removed

in a future Android release.

Opens a DEX file from a given File object.

Parameters

file

File

DexFile

public DexFile (String fileName)

This constructor is deprecated.

Applications should use one of the standard classloaders such

as This API will be removed

in a future Android release.

Opens a DEX file from a given filename.

Parameters

fileName

String

Public methods

close

public void close ()

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.

Throws

if an I/O error occurs during closing the file, which

normally should not happen

entries

public Enumeration entries ()

Enumerate the names of the classes in this DEX file.

Returns

an enumeration of names of classes contained in the DEX file, in

the usual internal form (like "java/lang/String").

getName

public String getName ()

Gets the name of the (already opened) DEX file.

Returns

the file name

isDexOptNeeded

public 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.

Parameters

fileName

String: the absolute path to the apk/jar file to examine.

Returns

boolean

true if dexopt should be called on the file, false otherwise.

Throws

if fileName is not readable,

not a file, or not present.

if fileName is not a valid apk/jar file or

if problems occur while parsing it.

if fileName is null.

loadClass

public Class loadClass (String name,

ClassLoader loader)

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

The method does not throw

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

Returns

the null

if the class cannot be loaded

loadDex

public static DexFile loadDex (String sourcePathName,

String outputPathName,

int flags)

This method was deprecated

in API level 26.

Applications should use one of the standard classloaders such

as 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.

Parameters

sourcePathName

String

outputPathName

String

flags

int

Returns

toString

public String toString ()

Returns a string representation of the object. In general, the

toString method returns a string that

"textually represents" this object. The result should

be a concise but informative representation that is easy for a

person to read.

It is recommended that all subclasses override this method.

The toString method for class Object

returns a string consisting of the name of the class of which the

object is an instance, the at-sign character `@', and

the unsigned hexadecimal representation of the hash code of the

object. In other words, this method returns a string equal to the

value of:getClass().getName() + '@' + Integer.toHexString(hashCode())

Returns

a string representation of the object.

Protected methods

finalize

protected void finalize ()

Called when the class is finalized. Makes sure the DEX file is closed.

Throws

if an I/O error occurs during closing the file, which

normally should not happen

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值