public class ClassFile
extends java.lang.Object
A ClassFile contains code for manipulation of its constituents.
Modifier and Type | Field and Description |
---|---|
int |
access_flags
Access flags for this Class.
|
soot.coffi.attribute_info[] |
attributes
Array of attribute_info objects for this class.
|
int |
attributes_count
Count of attributes this class contains.
|
soot.coffi.BootstrapMethods_attribute |
bootstrap_methods_attribute
bootstrap-methods attribute (if any)
|
soot.coffi.cp_info[] |
constant_pool
Array of constant pool items.
|
int |
constant_pool_count
Number of items in the constant pool.
|
field_info[] |
fields
Array of field_info objects describing each field.
|
int |
fields_count
Count of fields this Class contains.
|
int[] |
interfaces
Array of constant pool indices of Class constants describing each
interace implemented by this class, as given in the source for this
class.
|
int |
interfaces_count
Count of interfaces implemented.
|
method_info[] |
methods
Array of method_info objects describing each field.
|
int |
methods_count
Count of methods this Class contains.
|
int |
super_class
Constant pool index of the Class constant describing super.
|
int |
this_class
Constant pool index of the Class constant describing this.
|
Constructor and Description |
---|
ClassFile(java.lang.String nfn)
Creates a new ClassFile object given the name of the file.
|
Modifier and Type | Method and Description |
---|---|
boolean |
loadClassFile(java.io.InputStream is) |
void |
parse()
For every method, this calls parseMethod, storing the list of Instructions
in the method_info object, and also constructs the corresponding CFG.
|
soot.coffi.Instruction |
parseMethod(method_info m)
Parses the given method, converting its bytecode array into a list
of Instruction objects.
|
protected boolean |
readAttributes(java.io.DataInputStream d,
int attributes_count,
soot.coffi.attribute_info[] ai)
Reads in the given number of attributes from the given stream.
|
boolean |
readClass(java.io.DataInputStream d)
Builds the internal representation of this Class by reading in the
given class file.
|
protected boolean |
readConstantPool(java.io.DataInputStream d)
Reads in the constant pool from the given stream.
|
protected boolean |
readFields(java.io.DataInputStream d)
Reads in the fields from the given stream.
|
protected boolean |
readMethods(java.io.DataInputStream d)
Reads in the methods from the given stream.
|
java.lang.String |
toString()
Returns the name of this Class.
|
protected boolean |
writeAttributes(java.io.DataOutputStream dd,
int attributes_count,
soot.coffi.attribute_info[] ai)
Writes the given array of attributes to the given stream.
|
protected boolean |
writeConstantPool(java.io.DataOutputStream dd)
Writes the current constant pool to the given stream.
|
protected boolean |
writeFields(java.io.DataOutputStream dd)
Writes the fields to the given stream.
|
protected boolean |
writeMethods(java.io.DataOutputStream dd)
Writes the methods to the given stream.
|
public int constant_pool_count
public soot.coffi.cp_info[] constant_pool
cp_info
public int access_flags
public int this_class
CONSTANT_Class_info
public int super_class
CONSTANT_Class_info
public int interfaces_count
public int[] interfaces
CONSTANT_Class_info
public int fields_count
public field_info[] fields
field_info
public int methods_count
public method_info[] methods
method_info
public int attributes_count
public soot.coffi.attribute_info[] attributes
attribute_info
public soot.coffi.BootstrapMethods_attribute bootstrap_methods_attribute
public ClassFile(java.lang.String nfn)
nfn
- file name which this ClassFile will represent.public java.lang.String toString()
toString
in class java.lang.Object
public boolean loadClassFile(java.io.InputStream is)
public boolean readClass(java.io.DataInputStream d)
d
- Stream forming the .class file.protected boolean readConstantPool(java.io.DataInputStream d) throws java.io.IOException
d
- Stream forming the .class file.java.io.IOException
- on error.protected boolean readAttributes(java.io.DataInputStream d, int attributes_count, soot.coffi.attribute_info[] ai) throws java.io.IOException
d
- Stream forming the .class file.attributes_count
- number of attributes to read in.ai
- pre-allocated array of attributes to be filled in.java.io.IOException
- on error.protected boolean readFields(java.io.DataInputStream d) throws java.io.IOException
d
- Stream forming the .class file.java.io.IOException
- on error.protected boolean readMethods(java.io.DataInputStream d) throws java.io.IOException
d
- Stream forming the .class file.java.io.IOException
- on error.protected boolean writeConstantPool(java.io.DataOutputStream dd) throws java.io.IOException
dd
- output stream.java.io.IOException
- on error.protected boolean writeAttributes(java.io.DataOutputStream dd, int attributes_count, soot.coffi.attribute_info[] ai) throws java.io.IOException
dd
- output stream.attributes_count
- number of attributes to write.ai
- array of attributes to write.java.io.IOException
- on error.protected boolean writeFields(java.io.DataOutputStream dd) throws java.io.IOException
dd
- output stream.java.io.IOException
- on error.protected boolean writeMethods(java.io.DataOutputStream dd) throws java.io.IOException
dd
- output stream.java.io.IOException
- on error.public soot.coffi.Instruction parseMethod(method_info m)
m
- method to parse.Instruction
,
ByteCode
,
ByteCode.disassemble_bytecode(byte[], int)
public void parse()
parseMethod(soot.coffi.method_info)
,
CFG