Package com.android.dx.cf.direct
Class DirectClassFile
java.lang.Object
com.android.dx.cf.direct.DirectClassFile
- All Implemented Interfaces:
ClassFile
,HasAttribute
Class file with info taken from a
byte[]
or slice thereof.-
Constructor Summary
ConstructorDescriptionDirectClassFile
(byte[] bytes, String filePath, boolean strictParse) Constructs an instance.DirectClassFile
(ByteArray bytes, String filePath, boolean strictParse) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the fieldaccess_flags
.Gets the fieldattributes
(along withattributes_count
).Gets the bootstrap methodattributes
.getBytes()
Gets theByteArray
that this instance's data comes from.Gets the fieldconstant_pool
(along withconstant_pool_count
).Gets the fieldfields
(along withfields_count
).Gets the path where this class file is located.Gets the fieldinterfaces
(along withinterfaces_count
).int
getMagic()
Gets the fieldmagic
.int
Gets the class file fieldmagic
, but without doing any checks or parsing first.int
Gets the fieldmajor_version
.int
Gets the class file fieldmajor_version
, but without doing any checks or parsing first.Gets the fieldmethods
(along withmethods_count
).int
Gets the fieldminor_version
.int
Gets the class file fieldminor_version
, but without doing any checks or parsing first.Gets the name out of theSourceFile
attribute of this file, if any.Gets the fieldsuper_class
, interpreted as a type constant if non-zero.Gets the fieldthis_class
, interpreted as a type constant.makeTypeList
(int offset, int size) Constructs and returns an instance ofTypeList
whose data comes from the bytes of this instance, interpreted as a list of constant pool indices for classes, which are in turn translated to type constants.void
setAttributeFactory
(AttributeFactory attributeFactory) Sets the attribute factory to use.void
setObserver
(ParseObserver observer) Sets the parse observer for this instance.static String
stringOrNone
(Object obj) Returns the string form of an object or"(none)"
(rather than"null"
) fornull
.
-
Constructor Details
-
DirectClassFile
Constructs an instance.- Parameters:
bytes
-non-null;
the bytes of the filefilePath
-non-null;
the file path for the class, excluding any base directory specificationstrictParse
- whether to be strict about parsing; iffalse
, this avoids doing checks that only exist for purposes of verification (such as magic number matching and path-package consistency checking)
-
DirectClassFile
Constructs an instance.- Parameters:
bytes
-non-null;
the bytes of the filefilePath
-non-null;
the file path for the class, excluding any base directory specificationstrictParse
- whether to be strict about parsing; iffalse
, this avoids doing checks that only exist for purposes of verification (such as magic number matching and path-package consistency checking)
-
-
Method Details
-
stringOrNone
Returns the string form of an object or"(none)"
(rather than"null"
) fornull
.- Parameters:
obj
-null-ok;
the object to stringify- Returns:
non-null;
the appropriate string form
-
setObserver
Sets the parse observer for this instance.- Parameters:
observer
-null-ok;
the observer
-
setAttributeFactory
Sets the attribute factory to use.- Parameters:
attributeFactory
-non-null;
the attribute factory
-
getFilePath
Gets the path where this class file is located.- Returns:
non-null;
the filePath
-
getBytes
Gets theByteArray
that this instance's data comes from.- Returns:
non-null;
the bytes
-
getMagic
public int getMagic()Gets the fieldmagic
. -
getMinorVersion
public int getMinorVersion()Gets the fieldminor_version
.- Specified by:
getMinorVersion
in interfaceClassFile
- Returns:
- the value in question
-
getMajorVersion
public int getMajorVersion()Gets the fieldmajor_version
.- Specified by:
getMajorVersion
in interfaceClassFile
- Returns:
- the value in question
-
getAccessFlags
public int getAccessFlags()Gets the fieldaccess_flags
.- Specified by:
getAccessFlags
in interfaceClassFile
- Returns:
- the value in question
-
getThisClass
Gets the fieldthis_class
, interpreted as a type constant.- Specified by:
getThisClass
in interfaceClassFile
- Returns:
non-null;
the value in question
-
getSuperclass
Gets the fieldsuper_class
, interpreted as a type constant if non-zero.- Specified by:
getSuperclass
in interfaceClassFile
- Returns:
null-ok;
the value in question
-
getConstantPool
Gets the fieldconstant_pool
(along withconstant_pool_count
).- Specified by:
getConstantPool
in interfaceClassFile
- Returns:
non-null;
the constant pool
-
getInterfaces
Gets the fieldinterfaces
(along withinterfaces_count
).- Specified by:
getInterfaces
in interfaceClassFile
- Returns:
non-null;
the list of interfaces
-
getFields
Gets the fieldfields
(along withfields_count
). -
getMethods
Gets the fieldmethods
(along withmethods_count
).- Specified by:
getMethods
in interfaceClassFile
- Returns:
non-null;
the list of fields
-
getAttributes
Gets the fieldattributes
(along withattributes_count
).- Specified by:
getAttributes
in interfaceClassFile
- Specified by:
getAttributes
in interfaceHasAttribute
- Returns:
non-null;
the list of attributes
-
getBootstrapMethods
Gets the bootstrap methodattributes
.- Specified by:
getBootstrapMethods
in interfaceClassFile
- Returns:
non-null;
the list of bootstrap methods
-
getSourceFile
Gets the name out of theSourceFile
attribute of this file, if any. This is a convenient shorthand for scrounging around the class's attributes.- Specified by:
getSourceFile
in interfaceClassFile
- Returns:
non-null;
the constant pool
-
makeTypeList
Constructs and returns an instance ofTypeList
whose data comes from the bytes of this instance, interpreted as a list of constant pool indices for classes, which are in turn translated to type constants. Instance construction will fail if any of the (alleged) indices turn out not to refer to constant pool entries of typeClass
.- Parameters:
offset
- offset intobytes
for the start of the datasize
- number of elements in the list (not number of bytes)- Returns:
non-null;
an appropriately-constructed class list
-
getMagic0
public int getMagic0()Gets the class file fieldmagic
, but without doing any checks or parsing first.- Returns:
- the magic value
-
getMinorVersion0
public int getMinorVersion0()Gets the class file fieldminor_version
, but without doing any checks or parsing first.- Returns:
- the minor version
-
getMajorVersion0
public int getMajorVersion0()Gets the class file fieldmajor_version
, but without doing any checks or parsing first.- Returns:
- the major version
-