class ClassReader extends java.lang.Object
A Java class parser to make a org.springframework.asm.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.
Modifiers | Name | Description |
---|---|---|
static int |
ACC_SYNTHETIC_ATTRIBUTE |
Pseudo access flag to distinguish between the synthetic attribute and the synthetic access flag. |
private static boolean |
ANNOTATIONS |
True to enable annotations support. |
static int |
CLASS |
The type of CONSTANT_Class constant pool items. |
static int |
DOUBLE |
The type of CONSTANT_Double constant pool items. |
static int |
FIELD |
The type of CONSTANT_Fieldref constant pool items. |
static int |
FLOAT |
The type of CONSTANT_Float constant pool items. |
private static int |
HANDLE |
The type of CONSTANT_MethodHandle constant pool items. |
static int |
IMETH |
The type of CONSTANT_InterfaceMethodref constant pool items. |
private static int |
INDY |
The type of CONSTANT_InvokeDynamic constant pool items. |
static int |
INT |
The type of CONSTANT_Integer constant pool items. |
static int |
LONG |
The type of CONSTANT_Long constant pool items. |
static int |
METH |
The type of CONSTANT_Methodref constant pool items. |
static int |
MTYPE |
The type of CONSTANT_MethodType constant pool items. |
static int |
NAME_TYPE |
The type of CONSTANT_NameAndType constant pool items. |
private static boolean |
SIGNATURES |
True to enable signatures support. |
static int |
SKIP_DEBUG |
Flag to skip the debug information in the class. |
static int |
STR |
The type of CONSTANT_String constant pool items. |
static int |
UTF8 |
The type of CONSTANT_Utf8 constant pool items. |
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 and description |
---|
private ClassReader
(byte[] b) Constructs a new org.springframework.asm.ClassReader object. |
private ClassReader
(byte[] b, int off, int len) Constructs a new org.springframework.asm.ClassReader object. |
ClassReader
(java.io.InputStream is) Constructs a new org.springframework.asm.ClassReader object. |
Type Params | Return Type | Name and description |
---|---|---|
|
public void |
accept(org.springframework.asm.ClassVisitor classVisitor, int flags) Makes the given visitor visit the Java class of this org.springframework.asm.ClassReader . |
|
public void |
accept(org.springframework.asm.ClassVisitor classVisitor, Attribute[] attrs, int flags) Makes the given visitor visit the Java class of this org.springframework.asm.ClassReader. |
|
private int |
getAttributes() Returns the start index of the attribute_info structure of this class. |
|
private int |
readAnnotationValue(int v, char[] buf, java.lang.String name, org.springframework.asm.AnnotationVisitor av) Reads a value of an annotation and makes the given visitor visit it. |
|
private int |
readAnnotationValues(int v, char[] buf, boolean named, org.springframework.asm.AnnotationVisitor av) Reads the values of an annotation and makes the given visitor visit them. |
|
private Attribute |
readAttribute(Attribute[] attrs, java.lang.String type, int off, int len, char[] buf, int codeOff, org.springframework.asm.Label[] labels) Reads an attribute in b. |
|
private int |
readByte(int index) Reads a byte value in b. |
|
private static byte[] |
readClass(java.io.InputStream is, boolean close) Reads the bytecode of a class. |
|
java.lang.String |
readClass(int index, char[] buf) Reads a class constant pool item in b. |
|
java.lang.Object |
readConst(int item, char[] buf) Reads a numeric or string constant pool item in b. |
|
private int |
readInt(int index) Reads a signed int value in b. |
|
private long |
readLong(int index) Reads a signed long value in b. |
|
private java.lang.String |
readUTF(int index, int utfLen, char[] buf) Reads UTF8 string in b. |
|
java.lang.String |
readUTF8(int index, char[] buf) Reads an UTF8 string constant pool item in b. |
|
private int |
readUnsignedShort(int index) Reads an unsigned short value in b. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Pseudo access flag to distinguish between the synthetic attribute and the synthetic access flag.
True to enable annotations support.
The type of CONSTANT_Class constant pool items.
The type of CONSTANT_Double constant pool items.
The type of CONSTANT_Fieldref constant pool items.
The type of CONSTANT_Float constant pool items.
The type of CONSTANT_MethodHandle constant pool items.
The type of CONSTANT_InterfaceMethodref constant pool items.
The type of CONSTANT_InvokeDynamic constant pool items.
The type of CONSTANT_Integer constant pool items.
The type of CONSTANT_Long constant pool items.
The type of CONSTANT_Methodref constant pool items.
The type of CONSTANT_MethodType constant pool items.
The type of CONSTANT_NameAndType constant pool items.
True to enable signatures support.
Flag to skip the debug information in the class. If this flag is set the debug information of the class is not visited, i.e. the org.springframework.asm.MethodVisitor#visitLocalVariable and org.springframework.asm.MethodVisitor#visitLineNumber methods will not be called.
The type of CONSTANT_String constant pool items.
The type of CONSTANT_Utf8 constant pool items.
The class to be parsed. The content of this array must not be modified. This field is intended for org.springframework.asm.Attribute sub classes, and is normally not needed by class generators or adapters.
Start index of the class header information (access, name...) in b.
The start index of each constant pool item in b, plus one. The one byte offset skips the constant pool item tag that indicates its type.
Maximum length of the strings contained in the constant pool of the class.
The String objects corresponding to the CONSTANT_Utf8 items. This cache avoids multiple parsing of a given CONSTANT_Utf8 constant pool item, which GREATLY improves performances (by a factor 2 to 3). This caching strategy could be extended to all constant pool items, but its benefit would not be so great for these items (because they are much less expensive to parse than CONSTANT_Utf8 items).
Constructs a new org.springframework.asm.ClassReader object.
b
- the bytecode of the class to be read.Constructs a new org.springframework.asm.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.Constructs a new org.springframework.asm.ClassReader object.
is
- an input stream from which to read the class.Makes the given visitor visit the Java class of this org.springframework.asm.ClassReader . This class is the one specified in the constructor (see ClassReader).
classVisitor
- the visitor that must visit this class.Makes the given visitor visit the Java class of this org.springframework.asm.ClassReader. This class is the one specified in the constructor (see ClassReader).
classVisitor
- the visitor that must visit this class.attrs
- prototypes of the attributes that must be parsed during the
visit of the class. Any attribute whose type is not equal to
the type of one the prototypes will not be parsed: its byte
array value will be passed unchanged to the ClassWriter.
This may corrupt it if this value contains references to
the constant pool, or has syntactic or semantic links with a
class element that has been transformed by a class adapter
between the reader and the writer.Returns the start index of the attribute_info structure of this class.
Reads a value of an annotation and makes the given visitor visit it.
v
- the start offset in b of the value to be read
(not including the value name constant pool index).buf
- buffer to be used to call readUTF8,
readClass or readConst.name
- the name of the value to be read.av
- the visitor that must visit the value.Reads the values of an annotation and makes the given visitor visit them.
v
- the start offset in b of the values to be read
(including the unsigned short that gives the number of
values).buf
- buffer to be used to call readUTF8,
readClass or readConst.named
- if the annotation values are named or not.av
- the visitor that must visit the values.Reads an attribute in b.
attrs
- prototypes of the attributes that must be parsed during the
visit of the class. Any attribute whose type is not equal to
the type of one the prototypes is ignored (i.e. an empty
org.springframework.asm.Attribute instance is returned).type
- the type of the attribute.off
- index of 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.codeOff
- index of the first byte of code's attribute content in
b, or -1 if the attribute to be read is not a code
attribute. The 6 attribute header bytes, containing the type
and the length of the attribute, are not taken into account
here.labels
- the labels of the method's code, or null if the
attribute to be read is not a code attribute.Reads a byte value in b. This method is intended for org.springframework.asm.Attribute sub classes, and is normally not needed by class generators or adapters.
index
- the start index of the value to be read in b.Reads the bytecode of a class.
is
- an input stream from which to read the class.close
- true to close the input stream after reading.Reads a class constant pool item in b. This method is intended for org.springframework.asm.Attribute sub classes, and is normally not needed by class generators or adapters.
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.Reads a numeric or string constant pool item in b. This method is intended for org.springframework.asm.Attribute sub classes, and is normally not needed by class generators or adapters.
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.Reads a signed int value in b. This method is intended for org.springframework.asm.Attribute sub classes, and is normally not needed by class generators or adapters.
index
- the start index of the value to be read in b.Reads a signed long value in b. This method is intended for org.springframework.asm.Attribute sub classes, and is normally not needed by class generators or adapters.
index
- the start index of the value to be read in b.Reads UTF8 string in b.
index
- start offset of the UTF8 string to be read.utfLen
- length of the UTF8 string to be read.buf
- buffer to be used to read the string. This buffer must be
sufficiently large. It is not automatically resized.Reads an UTF8 string constant pool item in b. This method is intended for org.springframework.asm.Attribute sub classes, and is normally not needed by class generators or adapters.
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.