All Packages Class Hierarchy This Package Previous Next Index
Class espresso.classfile.javaclass.ClassParser
java.lang.Object
|
+----espresso.classfile.javaclass.ClassParser
- public final class ClassParser
- extends Object
- implements Constants
Wrapper class that parses a given Java .class file. The method
parse returns a
JavaClass object on success. When an I/O error or an
inconsistency occurs an appropiate exception is propagated back
to the caller.
The structure and the names comply, except for a few conveniences,
exactly with the
JVM specification 1.0. See this paper for
further details about the structure of a bytecode file.
-
access_flags
-
-
attributes
-
-
class_name_index
-
-
constant_pool
-
-
fields
-
-
file
-
-
file_name
-
-
interfaces
-
-
major
-
-
methods
-
-
minor
-
-
superclass_name_index
-
-
ClassParser(InputStream, String)
- Parse class from the given stream.
-
ClassParser(String)
- Parse class from given .class file.
-
ClassParser(String, String)
- Parse class from given .class file in a ZIP-archive
-
parse()
- Parse the given Java class file and return an object that represents
the contained data, i.e.
-
readAttributes()
- Read information about the attributes of the attributes of the class.
-
readClassInfo()
- Read information about the class and its super class.
-
readConstantPool()
- Read constant pool entries.
-
readFields()
- Read information about the fields of the class, i.e.
-
readID()
- Check whether the header of the file is ok.
-
readInterfaces()
- Read information about the interfaces implemented by this class.
-
readMethods()
- Read information about the methods of the class.
-
readVersion()
- Read major and minor version of compiler which created the file.
file
private DataInputStream file
file_name
private String file_name
class_name_index
private int class_name_index
superclass_name_index
private int superclass_name_index
major
private int major
minor
private int minor
access_flags
private int access_flags
interfaces
private int interfaces[]
constant_pool
private ConstantPool constant_pool
fields
private Field fields[]
methods
private Method methods[]
attributes
private Attribute attributes[]
ClassParser
public ClassParser(InputStream file,
String file_name)
- Parse class from the given stream.
- Parameters:
- file - Input stream
- file_name - File name
ClassParser
public ClassParser(String file_name) throws IOException
- Parse class from given .class file.
- Parameters:
- file_name - file name
ClassParser
public ClassParser(String zip_file,
String file_name) throws IOException
- Parse class from given .class file in a ZIP-archive
- Parameters:
- file_name - file name
parse
public JavaClass parse() throws IOException, ClassFormatError
- Parse the given Java class file and return an object that represents
the contained data, i.e. constants, methods, fields and commands.
A ClassFormatError is raised, if the file is not a valid
.class file. (This does not include verification of the byte code as it
is performed by the java interpreter).
- Returns:
- Class object representing the parsed class file
readAttributes
private final void readAttributes() throws IOException, ClassFormatError
- Read information about the attributes of the attributes of the class.
readClassInfo
private final void readClassInfo() throws IOException, ClassFormatError
- Read information about the class and its super class.
readConstantPool
private final void readConstantPool() throws IOException, ClassFormatError
- Read constant pool entries.
readFields
private final void readFields() throws IOException, ClassFormatError
- Read information about the fields of the class, i.e. its variables.
readID
private final void readID() throws IOException, ClassFormatError
- Check whether the header of the file is ok.
Of course, this has to be the first action on successive file reads.
readInterfaces
private final void readInterfaces() throws IOException, ClassFormatError
- Read information about the interfaces implemented by this class.
readMethods
private final void readMethods() throws IOException, ClassFormatError
- Read information about the methods of the class.
readVersion
private final void readVersion() throws IOException, ClassFormatError
- Read major and minor version of compiler which created the file.
All Packages Class Hierarchy This Package Previous Next Index