|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.logicalcobwebs.asm.ClassReader
public class ClassReader
A Java class parser to make a ClassVisitor visit an
existing class. This class parses a byte array conforming to the Java class
file format and calls the appropriate visit methods of a given class visitor
for each field, method and bytecode instruction encountered.
| Field Summary | |
|---|---|
protected byte[] |
b
The class to be parsed. |
private int |
header
Start index of the class header information (access, name...) in b. |
private int[] |
items
The start index of each constant pool item in b, plus one. |
private int |
maxStringLength
Maximum length of the strings contained in the constant pool of the class. |
private java.lang.String[] |
strings
The String objects corresponding to the CONSTANT_Utf8 items. |
| Constructor Summary | |
|---|---|
ClassReader(byte[] b)
Constructs a new ClassReader object. |
|
ClassReader(byte[] b,
int off,
int len)
Constructs a new ClassReader object. |
|
ClassReader(java.io.InputStream is)
Constructs a new ClassReader object. |
|
ClassReader(java.lang.String name)
Constructs a new ClassReader object. |
|
| Method Summary | |
|---|---|
void |
accept(ClassVisitor classVisitor,
boolean skipDebug)
Makes the given visitor visit the Java class of this ClassReader. |
protected Attribute |
readAttribute(java.lang.String type,
int off,
int len,
char[] buf)
Reads an attribute in b. |
private static byte[] |
readClass(java.io.InputStream is)
Reads the bytecode of a class. |
protected java.lang.String |
readClass(int index,
char[] buf)
Reads a class constant pool item in b. |
protected java.lang.Object |
readConst(int item,
char[] buf)
Reads a numeric or string constant pool item in b. |
protected int |
readInt(int index)
Reads a signed int value in b. |
protected long |
readLong(int index)
Reads a signed long value in b. |
protected short |
readShort(int index)
Reads a signed short value in b. |
protected int |
readUnsignedShort(int index)
Reads an unsigned short value in b. |
protected java.lang.String |
readUTF8(int index,
char[] buf)
Reads an UTF8 constant pool item in b. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final byte[] b
private int[] items
b, plus one. The
one byte offset skips the constant pool item tag that indicates its type.
private java.lang.String[] strings
private int maxStringLength
private int header
b.
| Constructor Detail |
|---|
public ClassReader(byte[] b)
ClassReader object.
b - the bytecode of the class to be read.
public ClassReader(byte[] b,
int off,
int len)
ClassReader object.
b - the bytecode of the class to be read.off - the start offset of the class data.len - the length of the class data.
public ClassReader(java.io.InputStream is)
throws java.io.IOException
ClassReader object.
is - an input stream from which to read the class.
java.io.IOException - if a problem occurs during reading.
public ClassReader(java.lang.String name)
throws java.io.IOException
ClassReader object.
name - the fully qualified name of the class to be read.
java.io.IOException - if an exception occurs during reading.| Method Detail |
|---|
private static byte[] readClass(java.io.InputStream is)
throws java.io.IOException
is - an input stream from which to read the class.
java.io.IOException - if a problem occurs during reading.
public void accept(ClassVisitor classVisitor,
boolean skipDebug)
ClassReader. This class is the one specified in the constructor (see
ClassReader).
classVisitor - the visitor that must visit this class.skipDebug - true if the debug information of the class must
not be visited. In this case the visitLocalVariable and visitLineNumber methods will not be called.protected int readUnsignedShort(int index)
b.
index - the start index of the value to be read in b.
protected short readShort(int index)
b.
index - the start index of the value to be read in b.
protected int readInt(int index)
b.
index - the start index of the value to be read in b.
protected long readLong(int index)
b.
index - the start index of the value to be read in b.
protected java.lang.String readUTF8(int index,
char[] buf)
b.
index - the start index of an unsigned short value in b,
whose value is the index of an UTF8 constant pool item.buf - buffer to be used to read the item. This buffer must be
sufficiently large. It is not automatically resized.
protected java.lang.String readClass(int index,
char[] buf)
b.
index - the start index of an unsigned short value in b,
whose value is the index of a class constant pool item.buf - buffer to be used to read the item. This buffer must be
sufficiently large. It is not automatically resized.
protected java.lang.Object readConst(int item,
char[] buf)
b.
item - the index of a constant pool item.buf - buffer to be used to read the item. This buffer must be
sufficiently large. It is not automatically resized.
Integer, Float, Long, Double
or String corresponding to the given constant pool
item.
protected Attribute readAttribute(java.lang.String type,
int off,
int len,
char[] buf)
b. The default implementation of this
method returns instances of the Attribute class for all attributes.
type - the type of the attribute.off - the first byte of the attribute's content in b. The
6 attribute header bytes, containing the type and the length of the
attribute, are not taken into account here (they have already been
read).len - the length of the attribute's content.buf - buffer to be used to call readUTF8, readClass or readConst.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||