public final class ClassReader extends java.lang.Object implements ClassConstants
ClassReader performs lazy parsing, and thus most of the methods can throw an InvalidClassFileException.
| Modifier and Type | Class and Description |
|---|---|
static class |
ClassReader.AttrIterator
AttrIterator provides access to attributes in the class file.
|
ACC_ABSTRACT, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_TRANSIENT, ACC_VOLATILE, CONSTANT_Class, CONSTANT_Double, CONSTANT_FieldRef, CONSTANT_Float, CONSTANT_Integer, CONSTANT_InterfaceMethodRef, CONSTANT_InvokeDynamic, CONSTANT_Long, CONSTANT_MethodHandle, CONSTANT_MethodRef, CONSTANT_MethodType, CONSTANT_NameAndType, CONSTANT_String, CONSTANT_Utf8, MAGIC, REF_getField, REF_getStatic, REF_invokeInterface, REF_invokeSpecial, REF_invokeStatic, REF_invokeVirtual, REF_newInvokeSpecial, REF_putField, REF_putStatic| Constructor and Description |
|---|
ClassReader(byte[] bytes)
Build a reader.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getAccessFlags() |
byte |
getByte(int i) |
byte[] |
getBytes() |
ConstantPoolParser |
getCP()
This method allows direct read-only access to the constant pool for the class.
|
int |
getFieldAccessFlags(int f) |
int |
getFieldCount() |
java.lang.String |
getFieldName(int f) |
int |
getFieldNameIndex(int f) |
int |
getFieldRawOffset(int f) |
int |
getFieldRawSize(int f) |
java.lang.String |
getFieldType(int f) |
int |
getFieldTypeIndex(int f) |
int |
getInt(int i) |
int |
getInterfaceCount() |
java.lang.String |
getInterfaceName(int i) |
int |
getInterfaceNameIndex(int i) |
int[] |
getInterfaceNameIndices() |
java.lang.String[] |
getInterfaceNames() |
int |
getMagic() |
int |
getMajorVersion() |
int |
getMethodAccessFlags(int m) |
int |
getMethodCount() |
java.lang.String |
getMethodName(int m) |
int |
getMethodNameIndex(int m) |
int |
getMethodRawOffset(int m) |
int |
getMethodRawSize(int m) |
java.lang.String |
getMethodType(int m) |
int |
getMethodTypeIndex(int m) |
int |
getMinorVersion() |
java.lang.String |
getName() |
int |
getNameIndex() |
int |
getShort(int i) |
java.lang.String |
getSuperName() |
int |
getSuperNameIndex() |
int |
getUnsignedByte(int i) |
int |
getUShort(int i) |
void |
initClassAttributeIterator(ClassReader.AttrIterator iter)
Point iter at the list of attributes for the class.
|
void |
initFieldAttributeIterator(int f,
ClassReader.AttrIterator iter)
Point iter at the list of attributes for field f.
|
void |
initMethodAttributeIterator(int m,
ClassReader.AttrIterator iter)
Point iter at the list of attributes for method m.
|
public ClassReader(byte[] bytes)
throws InvalidClassFileException
If the class file data is corrupt an exception might not be thrown immediately. Instead an exception might be thrown later, during the execution of some access method. This is a consequence of the 'lazy parsing' performed by ClassReader.
bytes - the class file dataInvalidClassFileException - the class file data is corruptpublic byte[] getBytes()
public int getMagic()
public int getMinorVersion()
public int getMajorVersion()
public int getAccessFlags()
public int getNameIndex()
public java.lang.String getName()
throws InvalidClassFileException
InvalidClassFileExceptionpublic int getSuperNameIndex()
public java.lang.String getSuperName()
throws InvalidClassFileException
InvalidClassFileExceptionpublic int getInterfaceCount()
public int getInterfaceNameIndex(int i)
public int[] getInterfaceNameIndices()
public java.lang.String getInterfaceName(int i)
throws InvalidClassFileException
InvalidClassFileExceptionpublic java.lang.String[] getInterfaceNames()
throws InvalidClassFileException
InvalidClassFileExceptionpublic ConstantPoolParser getCP()
public int getInt(int i)
public int getUShort(int i)
public int getShort(int i)
public byte getByte(int i)
public int getUnsignedByte(int i)
public int getFieldCount()
public int getFieldAccessFlags(int f)
public java.lang.String getFieldName(int f)
throws InvalidClassFileException
InvalidClassFileExceptionpublic java.lang.String getFieldType(int f)
throws InvalidClassFileException
InvalidClassFileExceptionpublic int getFieldNameIndex(int f)
public int getFieldTypeIndex(int f)
public void initFieldAttributeIterator(int f,
ClassReader.AttrIterator iter)
java.lang.IllegalArgumentException - if iter is nullpublic int getFieldRawOffset(int f)
public int getFieldRawSize(int f)
public int getMethodCount()
public int getMethodRawOffset(int m)
public int getMethodRawSize(int m)
public int getMethodAccessFlags(int m)
public java.lang.String getMethodName(int m)
throws InvalidClassFileException
InvalidClassFileExceptionpublic java.lang.String getMethodType(int m)
throws InvalidClassFileException
InvalidClassFileExceptionpublic int getMethodNameIndex(int m)
public int getMethodTypeIndex(int m)
public void initMethodAttributeIterator(int m,
ClassReader.AttrIterator iter)
java.lang.IllegalArgumentException - if iter is nullpublic void initClassAttributeIterator(ClassReader.AttrIterator iter)
java.lang.IllegalArgumentException - if iter is null