|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectharpoon.IR.RawClass.ClassFile
public class ClassFile
Represents a java bytecode class file.
Drawn from The Java Virtual Machine Specification.
HClass
Field Summary | |
---|---|
AccessFlags |
access_flags
The value of the access_flags item is a mask of
modifiers used with class and interface declarations. |
Attribute[] |
attributes
Each value of the attributes table must be a
variable-length attribute structure. |
Constant[] |
constant_pool
The constant_pool is a table of variable-length
structures representing various string constants, class names,
field names, and other constants that are referred to within the
ClassFile structure and its substructures. |
FieldInfo[] |
fields
Each value in the fields table must be a
variable-length field_info structure giving a
complete description of a field in the class or interface type. |
int[] |
interfaces
Each value in the interfaces array must be a valid
index into the constant_pool table. |
int |
major_version
The major version number of the compiler that produced this class file. |
MethodInfo[] |
methods
Each value in the methods table must be a
variable-length method_info structure giving a
complete description of and Java Virtual Machine code for a
method in the class or interface. |
int |
minor_version
The minor version number of the compiler that produced this class file. |
int |
super_class
For a class, the value of the super_class item
either must be zero or must be a valid index into the
constant_pool table. |
int |
this_class
The value of the this_class item must be a valid
index into the constant_pool table. |
Constructor Summary | |
---|---|
ClassFile(ClassDataInputStream in)
Create a ClassFile object by reading data from a
bytecode file. |
|
ClassFile(InputStream in)
Create a ClassFile object by reading data from a
bytecode file. |
Method Summary | |
---|---|
int |
attributes_count()
|
int |
constant_pool_count()
|
int |
fields_count()
|
static void |
indent(PrintWriter pw,
int indent,
String s)
Output string s to PrintWriter pw at
the given indentation level indent . |
int |
interfaces_count()
|
ConstantClass |
interfaces(int i)
Return the CONSTANT_Class_info entry in the
constant_pool corresponding to the value in
interfaces[i] . |
int |
methods_count()
|
void |
print(PrintWriter pw)
Pretty print this classfile structure. |
void |
print(PrintWriter pw,
int indent)
|
void |
read(ClassDataInputStream in)
|
ConstantClass |
super_class()
Return the CONSTANT_Class_info entry in the
constant_pool corresponding to the value of
super_class , or null if
super_class == 0. |
ConstantClass |
this_class()
Return the CONSTANT_Class_info entry in the
constant_pool corresponding to the value of
this_class . |
void |
write(ClassDataOutputStream out)
Write a class file object out to a java bytecode file. |
void |
write(OutputStream out)
Write a class file object out to a java bytecode file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int minor_version
class
file.
public int major_version
class
file.
public Constant[] constant_pool
constant_pool
is a table of variable-length
structures representing various string constants, class names,
field names, and other constants that are referred to within the
ClassFile
structure and its substructures.
The first entry of the constant_pool
table,
constant_pool[0]
, is reserved for internal use by a
Java Virtual Machine Implementation. That entry is not
present in the class
file.
public AccessFlags access_flags
access_flags
item is a mask of
modifiers used with class and interface declarations.
public int this_class
this_class
item must be a valid
index into the constant_pool
table. The
constant_pool
entry at that index must be a
CONSTANT_Class_info
structure representing the
class or interface defined by this class
file.
public int super_class
super_class
item
either must be zero or must be a valid index into the
constant_pool
table. If the value of the
super_class
item is nonzero, the
constant_pool
entry at that index must be a
CONSTANT_Class_info
structure representing the
superclass of the class defined by this class
file. Neither the superclass nor any of its superclasses may be
a final
class.
If the value of super_class
is zero, then this
class
file must represent that class
java.lang.Object
, the only class or interface
without a superclass.
For an interface, the value of super_class
must
always be a valid index into the constant_pool
table. The constant_pool
entry at that index must
be a CONSTANT_Class_info
structure representing the
class java.lang.Object
.
public int[] interfaces
interfaces
array must be a valid
index into the constant_pool
table. The
constant_pool
entry at each value of
interfaces[i]
must be a
CONSTANT_Class_info
structure representing an
interface which is a direct superinterface of this class or
interface type, in the left-to-right order given in the source
for the type.
public FieldInfo[] fields
fields
table must be a
variable-length field_info
structure giving a
complete description of a field in the class or interface type.
The fields
table includes only those fields that
are declared by this class or interface. It does not include
items representing fields that are inherited from superclasses
or superinterfaces.
public MethodInfo[] methods
methods
table must be a
variable-length method_info
structure giving a
complete description of and Java Virtual Machine code for a
method in the class or interface.
The method_info
structures represent all methods,
both instance methods and, for classes, class
(static
) methods, declared by this class or
interface type. The methods
table only includes
those items that are explicitly declared by this class.
Interfaces have only the single method
<clinit>
, the interface initialization
method. The methods
table does not include items
representing methods that are inherited from superclasses or
superinterfaces.
public Attribute[] attributes
attributes
table must be a
variable-length attribute structure. A ClassFile
structure can have any number of attributes associated with it.
The only attribute defined by this specification for the
attributes
table of a ClassFile
structure is the SourceFile
attribute.
Constructor Detail |
---|
public ClassFile(ClassDataInputStream in)
ClassFile
object by reading data from a
bytecode file.
public ClassFile(InputStream in)
ClassFile
object by reading data from a
bytecode file.
Method Detail |
---|
public void read(ClassDataInputStream in) throws IOException
IOException
public void write(ClassDataOutputStream out) throws IOException
IOException
public void write(OutputStream out) throws IOException
IOException
public ConstantClass this_class()
CONSTANT_Class_info
entry in the
constant_pool
corresponding to the value of
this_class
.
public ConstantClass super_class()
CONSTANT_Class_info
entry in the
constant_pool
corresponding to the value of
super_class
, or null
if
super_class
== 0.
public ConstantClass interfaces(int i)
CONSTANT_Class_info
entry in the
constant_pool
corresponding to the value in
interfaces[i]
.
public int constant_pool_count()
public int interfaces_count()
public int fields_count()
public int methods_count()
public int attributes_count()
public void print(PrintWriter pw)
public void print(PrintWriter pw, int indent)
public static void indent(PrintWriter pw, int indent, String s)
s
to PrintWriter pw
at
the given indentation level indent
.
pw
- the output destination.indent
- the indentation level to use.s
- the string to write.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |