Top Description Fields Constructors Methods
org.aspectj.apache.bcel.classfile

public final Class ClassParser

extends Object
Class Inheritance
Imports
java.io.BufferedInputStream, .ByteArrayInputStream, .DataInputStream, .FileInputStream, .IOException, .InputStream, org.aspectj.apache.bcel.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.
Author
M. Dahm
Version
$Id: ClassParser.java,v 1.6 2008/05/30 17:29:14 aclement Exp $

Field Summary

Modifier and TypeField and Description
private int
private Attribute[]
private static final int
private int
private ConstantPool
private Field[]
private DataInputStream
private String
private int[]
private int
private Method[]
private int
private static final int[]
private int

Constructor Summary

AccessConstructor and Description
public
ClassParser(InputStream file, String filename)

Parse class from the given stream

public
public
ClassParser(String file_name)

Parse class from given .class file

Method Summary

Modifier and TypeMethod and Description
public JavaClass
parse()

Parse the given Java class file and return an object that represents the contained data, i.e., constants, methods, fields and commands.

private final void
readAttributes()

Read information about the attributes of the class

private final void
readClassInfo()

Read information about the class and its super class

private final void
private final void
readFields()

Read information about the fields of the class

private final void
readID()

Check whether the header of the file is ok.

private final void
readInterfaces()

Read information about the interfaces implemented by this class

private final void
readMethods()

Read information about the methods of the class

private final void
readVersion()

Read major and minor version of compiler which created the file

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accessflagsback to summary
private int accessflags
attributesback to summary
private Attribute[] attributes
BUFSIZEback to summary
private static final int BUFSIZE
classnameIndexback to summary
private int classnameIndex
cpoolback to summary
private ConstantPool cpool
fieldsback to summary
private Field[] fields
fileback to summary
private DataInputStream file
filenameback to summary
private String filename
interfaceIndicesback to summary
private int[] interfaceIndices
majorback to summary
private int major
methodsback to summary
private Method[] methods
minorback to summary
private int minor
NO_INTERFACESback to summary
private static final int[] NO_INTERFACES
superclassnameIndexback to summary
private int superclassnameIndex

Constructor Detail

ClassParserback to summary
public ClassParser(InputStream file, String filename)

Parse class from the given stream

ClassParserback to summary
public ClassParser(ByteArrayInputStream baos, String filename)
ClassParserback to summary
public ClassParser(String file_name) throws IOException

Parse class from given .class file

Method Detail

parseback to summary
public JavaClass parse() throws IOException, ClassFormatException

Parse the given Java class file and return an object that represents the contained data, i.e., constants, methods, fields and commands. A ClassFormatException 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).

readAttributesback to summary
private final void readAttributes()

Read information about the attributes of the class

readClassInfoback to summary
private final void readClassInfo() throws IOException

Read information about the class and its super class

readConstantPoolback to summary
private final void readConstantPool() throws IOException
readFieldsback to summary
private final void readFields() throws IOException, ClassFormatException

Read information about the fields of the class

readIDback to summary
private final void readID() throws IOException

Check whether the header of the file is ok. Of course, this has to be the first action on successive file reads

readInterfacesback to summary
private final void readInterfaces() throws IOException

Read information about the interfaces implemented by this class

readMethodsback to summary
private final void readMethods() throws IOException

Read information about the methods of the class

readVersionback to summary
private final void readVersion() throws IOException

Read major and minor version of compiler which created the file