public final class ClassParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
access_flags |
private Attribute[] |
attributes |
private static int |
BUFSIZE |
private int |
class_name_index |
private ConstantPool |
constant_pool |
private Field[] |
fields |
private java.io.DataInputStream |
file |
private java.lang.String |
file_name |
private boolean |
fileOwned |
private int[] |
interfaces |
private boolean |
is_zip |
private int |
major |
private Method[] |
methods |
private int |
minor |
private int |
superclass_name_index |
private java.lang.String |
zip_file |
Constructor and Description |
---|
ClassParser(java.io.InputStream file,
java.lang.String file_name)
Parse class from the given stream.
|
ClassParser(java.lang.String file_name)
Parse class from given .class file.
|
ClassParser(java.lang.String zip_file,
java.lang.String file_name)
Parse class from given .class file in a ZIP-archive
|
Modifier and Type | Method and Description |
---|---|
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 void |
readAttributes()
Read information about the attributes of the class.
|
private void |
readClassInfo()
Read information about the class and its super class.
|
private void |
readConstantPool()
Read constant pool entries.
|
private void |
readFields()
Read information about the fields of the class, i.e., its variables.
|
private void |
readID()
Check whether the header of the file is ok.
|
private void |
readInterfaces()
Read information about the interfaces implemented by this class.
|
private void |
readMethods()
Read information about the methods of the class.
|
private void |
readVersion()
Read major and minor version of compiler which created the file.
|
private java.io.DataInputStream file
private boolean fileOwned
private java.lang.String file_name
private java.lang.String zip_file
private int class_name_index
private int superclass_name_index
private int major
private int minor
private int access_flags
private int[] interfaces
private ConstantPool constant_pool
private Field[] fields
private Method[] methods
private Attribute[] attributes
private boolean is_zip
private static final int BUFSIZE
public ClassParser(java.io.InputStream file, java.lang.String file_name)
file
- Input streamfile_name
- File namepublic ClassParser(java.lang.String file_name)
file_name
- file namepublic ClassParser(java.lang.String zip_file, java.lang.String file_name)
zip_file
- zip file namefile_name
- file namepublic JavaClass parse() throws java.io.IOException, ClassFormatException
java.io.IOException
ClassFormatException
private void readAttributes() throws java.io.IOException, ClassFormatException
java.io.IOException
ClassFormatException
private void readClassInfo() throws java.io.IOException, ClassFormatException
java.io.IOException
ClassFormatException
private void readConstantPool() throws java.io.IOException, ClassFormatException
java.io.IOException
ClassFormatException
private void readFields() throws java.io.IOException, ClassFormatException
java.io.IOException
ClassFormatException
private void readID() throws java.io.IOException, ClassFormatException
java.io.IOException
ClassFormatException
private void readInterfaces() throws java.io.IOException, ClassFormatException
java.io.IOException
ClassFormatException
private void readMethods() throws java.io.IOException, ClassFormatException
java.io.IOException
ClassFormatException
private void readVersion() throws java.io.IOException, ClassFormatException
java.io.IOException
ClassFormatException