public class DirectClassFile extends java.lang.Object implements ClassFile
byte[] or slice thereof.| Constructor and Description |
|---|
DirectClassFile(byte[] bytes,
java.lang.String filePath,
boolean strictParse)
Constructs an instance.
|
DirectClassFile(ByteArray bytes,
java.lang.String filePath,
boolean strictParse)
Constructs an instance.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getAccessFlags()
Gets the field
access_flags. |
AttributeList |
getAttributes()
Gets the field
attributes (along with
attributes_count). |
BootstrapMethodsList |
getBootstrapMethods()
Gets the bootstrap method
attributes. |
ByteArray |
getBytes()
Gets the
ByteArray that this instance's data comes from. |
ConstantPool |
getConstantPool()
Gets the field
constant_pool (along with
constant_pool_count). |
FieldList |
getFields()
Gets the field
fields (along with
fields_count). |
java.lang.String |
getFilePath()
Gets the path where this class file is located.
|
TypeList |
getInterfaces()
Gets the field
interfaces (along with
interfaces_count). |
int |
getMagic()
Gets the field
magic. |
int |
getMagic0()
Gets the class file field
magic, but without doing any
checks or parsing first. |
int |
getMajorVersion()
Gets the field
major_version. |
int |
getMajorVersion0()
Gets the class file field
major_version, but
without doing any checks or parsing first. |
MethodList |
getMethods()
Gets the field
methods (along with
methods_count). |
int |
getMinorVersion()
Gets the field
minor_version. |
int |
getMinorVersion0()
Gets the class file field
minor_version, but
without doing any checks or parsing first. |
CstString |
getSourceFile()
Gets the name out of the
SourceFile attribute of this
file, if any. |
CstType |
getSuperclass()
Gets the field
super_class, interpreted as a type constant
if non-zero. |
CstType |
getThisClass()
Gets the field
this_class, interpreted as a type constant. |
TypeList |
makeTypeList(int offset,
int size)
Constructs and returns an instance of
TypeList 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 java.lang.String |
stringOrNone(java.lang.Object obj)
Returns the string form of an object or
"(none)"
(rather than "null") for null. |
public DirectClassFile(ByteArray bytes, java.lang.String filePath, boolean strictParse)
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; if
false, this avoids doing checks that only exist
for purposes of verification (such as magic number matching and
path-package consistency checking)public DirectClassFile(byte[] bytes,
java.lang.String filePath,
boolean strictParse)
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; if
false, this avoids doing checks that only exist
for purposes of verification (such as magic number matching and
path-package consistency checking)public static java.lang.String stringOrNone(java.lang.Object obj)
"(none)"
(rather than "null") for null.obj - null-ok; the object to stringifynon-null; the appropriate string formpublic void setObserver(ParseObserver observer)
observer - null-ok; the observerpublic void setAttributeFactory(AttributeFactory attributeFactory)
attributeFactory - non-null; the attribute factorypublic java.lang.String getFilePath()
non-null; the filePathpublic ByteArray getBytes()
ByteArray that this instance's data comes from.non-null; the bytespublic int getMagic()
magic.public int getMinorVersion()
minor_version.getMinorVersion in interface ClassFilepublic int getMajorVersion()
major_version.getMajorVersion in interface ClassFilepublic int getAccessFlags()
access_flags.getAccessFlags in interface ClassFilepublic CstType getThisClass()
this_class, interpreted as a type constant.getThisClass in interface ClassFilenon-null; the value in questionpublic CstType getSuperclass()
super_class, interpreted as a type constant
if non-zero.getSuperclass in interface ClassFilenull-ok; the value in questionpublic ConstantPool getConstantPool()
constant_pool (along with
constant_pool_count).getConstantPool in interface ClassFilenon-null; the constant poolpublic TypeList getInterfaces()
interfaces (along with
interfaces_count).getInterfaces in interface ClassFilenon-null; the list of interfacespublic FieldList getFields()
fields (along with
fields_count).public MethodList getMethods()
methods (along with
methods_count).getMethods in interface ClassFilenon-null; the list of fieldspublic AttributeList getAttributes()
attributes (along with
attributes_count).getAttributes in interface ClassFilegetAttributes in interface HasAttributenon-null; the list of attributespublic BootstrapMethodsList getBootstrapMethods()
attributes.getBootstrapMethods in interface ClassFilenon-null; the list of bootstrap methodspublic CstString getSourceFile()
SourceFile attribute of this
file, if any. This is a convenient shorthand for scrounging around
the class's attributes.getSourceFile in interface ClassFilenon-null; the constant poolpublic TypeList makeTypeList(int offset, int size)
TypeList 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 type Class.offset - offset into bytes for the start of the
datasize - number of elements in the list (not number of bytes)non-null; an appropriately-constructed class listpublic int getMagic0()
magic, but without doing any
checks or parsing first.public int getMinorVersion0()
minor_version, but
without doing any checks or parsing first.public int getMajorVersion0()
major_version, but
without doing any checks or parsing first.Copyright © 2020. All Rights Reserved.