Class DirectClassFile
java.lang.Object
com.android.dx.cf.direct.DirectClassFile
- All Implemented Interfaces:
ClassFile, HasAttribute
-
Constructor Summary
ConstructorsConstructorDescriptionDirectClassFile(byte[] bytes, String filePath, boolean strictParse) Constructs an instance.DirectClassFile(ByteArray bytes, String filePath, boolean strictParse) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionintGets the fieldaccess_flags.Gets the fieldattributes(along withattributes_count).Gets the bootstrap methodattributes.getBytes()Gets theByteArraythat 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).intgetMagic()Gets the fieldmagic.intGets the class file fieldmagic, but without doing any checks or parsing first.intGets the fieldmajor_version.intGets the class file fieldmajor_version, but without doing any checks or parsing first.Gets the fieldmethods(along withmethods_count).intGets the fieldminor_version.intGets the class file fieldminor_version, but without doing any checks or parsing first.Gets the name out of theSourceFileattribute 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 ofTypeListwhose 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.voidsetAttributeFactory(AttributeFactory attributeFactory) Sets the attribute factory to use.voidsetObserver(ParseObserver observer) Sets the parse observer for this instance.static StringstringOrNone(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
-
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
-
getMagic
-
getMinorVersion
public int getMinorVersion()Gets the fieldminor_version.- Specified by:
getMinorVersionin interfaceClassFile- Returns:
- the value in question
-
getMajorVersion
public int getMajorVersion()Gets the fieldmajor_version.- Specified by:
getMajorVersionin interfaceClassFile- Returns:
- the value in question
-
getAccessFlags
public int getAccessFlags()Gets the fieldaccess_flags.- Specified by:
getAccessFlagsin interfaceClassFile- Returns:
- the value in question
-
getThisClass
Gets the fieldthis_class, interpreted as a type constant.- Specified by:
getThisClassin interfaceClassFile- Returns:
non-null;the value in question
-
getSuperclass
Gets the fieldsuper_class, interpreted as a type constant if non-zero.- Specified by:
getSuperclassin interfaceClassFile- Returns:
null-ok;the value in question
-
getConstantPool
Gets the fieldconstant_pool(along withconstant_pool_count).- Specified by:
getConstantPoolin interfaceClassFile- Returns:
non-null;the constant pool
-
getInterfaces
Gets the fieldinterfaces(along withinterfaces_count).- Specified by:
getInterfacesin interfaceClassFile- Returns:
non-null;the list of interfaces
-
getFields
-
getMethods
Gets the fieldmethods(along withmethods_count).- Specified by:
getMethodsin interfaceClassFile- Returns:
non-null;the list of fields
-
getAttributes
Gets the fieldattributes(along withattributes_count).- Specified by:
getAttributesin interfaceClassFile- Specified by:
getAttributesin interfaceHasAttribute- Returns:
non-null;the list of attributes
-
getBootstrapMethods
Gets the bootstrap methodattributes.- Specified by:
getBootstrapMethodsin interfaceClassFile- Returns:
non-null;the list of bootstrap methods
-
getSourceFile
Gets the name out of theSourceFileattribute of this file, if any. This is a convenient shorthand for scrounging around the class's attributes.- Specified by:
getSourceFilein interfaceClassFile- Returns:
non-null;the constant pool
-
makeTypeList
Constructs and returns an instance ofTypeListwhose 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 intobytesfor 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
-