All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class harpoon.ClassFile.Raw.ClassFile

java.lang.Object
   |
   +----harpoon.ClassFile.Raw.ClassFile

public class ClassFile
extends Object
Represents a java bytecode class file.

Drawn from The Java Virtual Machine Specification.

Version:
$Id: ClassFile.java,v 1.16 1998/10/11 03:01:12 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
HClass

Variable Index

 o access_flags
The value of the access_flags item is a mask of modifiers used with class and interface declarations.
 o attributes
Each value of the attributes table must be a variable-length attribute structure.
 o 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.
 o 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.
 o interfaces
Each value in the interfaces array must be a valid index into the constant_pool table.
 o major_version
The major version number of the compiler that produced this class file.
 o 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.
 o minor_version
The minor version number of the compiler that produced this class file.
 o 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.
 o this_class
The value of the this_class item must be a valid index into the constant_pool table.

Constructor Index

 o ClassFile(ClassDataInputStream)
Create a ClassFile object by reading data from a bytecode file.
 o ClassFile(InputStream)
Create a ClassFile object by reading data from a bytecode file.

Method Index

 o attributes_count()
 o constant_pool_count()
 o fields_count()
 o indent(PrintWriter, int, String)
Output string s to PrintWriter pw at the given indentation level indent.
 o interfaces(int)
Return the CONSTANT_Class_info entry in the constant_pool corresponding to the value in interfaces[i].
 o interfaces_count()
 o methods_count()
 o print(PrintWriter)
Pretty print this classfile structure.
 o print(PrintWriter, int)
 o read(ClassDataInputStream)
 o 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.
 o this_class()
Return the CONSTANT_Class_info entry in the constant_pool corresponding to the value of this_class.
 o write(ClassDataOutputStream)
Write a class file object out to a java bytecode file.
 o write(OutputStream)
Write a class file object out to a java bytecode file.

Variables

 o minor_version
 public int minor_version
The minor version number of the compiler that produced this class file.

 o major_version
 public int major_version
The major version number of the compiler that produced this class file.

 o constant_pool
 public 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. 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.

 o access_flags
 public AccessFlags access_flags
The value of the access_flags item is a mask of modifiers used with class and interface declarations.

 o this_class
 public int this_class
The value of the 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.

 o super_class
 public 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. 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.

 o interfaces
 public int interfaces[]
Each value in the 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.

 o fields
 public 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. 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.

 o methods
 public 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.

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.

 o attributes
 public Attribute attributes[]
Each value of the 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.

Constructors

 o ClassFile
 public ClassFile(ClassDataInputStream in)
Create a ClassFile object by reading data from a bytecode file.

 o ClassFile
 public ClassFile(InputStream in)
Create a ClassFile object by reading data from a bytecode file.

Methods

 o read
 public void read(ClassDataInputStream in) throws IOException
 o write
 public void write(ClassDataOutputStream out) throws IOException
Write a class file object out to a java bytecode file.

 o write
 public void write(OutputStream out) throws IOException
Write a class file object out to a java bytecode file.

 o this_class
 public ConstantClass this_class()
Return the CONSTANT_Class_info entry in the constant_pool corresponding to the value of this_class.

 o super_class
 public 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.

 o interfaces
 public ConstantClass interfaces(int i)
Return the CONSTANT_Class_info entry in the constant_pool corresponding to the value in interfaces[i].

 o constant_pool_count
 public int constant_pool_count()
 o interfaces_count
 public int interfaces_count()
 o fields_count
 public int fields_count()
 o methods_count
 public int methods_count()
 o attributes_count
 public int attributes_count()
 o print
 public void print(PrintWriter pw)
Pretty print this classfile structure.

 o print
 public void print(PrintWriter pw,
                   int indent)
 o indent
 public static void indent(PrintWriter pw,
                           int indent,
                           String s)
Output string s to PrintWriter pw at the given indentation level indent.

Parameters:
pw - the output destination.
indent - the indentation level to use.
s - the string to write.

All Packages  Class Hierarchy  This Package  Previous  Next  Index