|
ej-technologies | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gjt.jclasslib.structures.AbstractStructure
org.gjt.jclasslib.structures.AbstractStructureWithAttributes
org.gjt.jclasslib.structures.ClassFile
The class file structure in which all other structures are hooked up.
Field Summary | |
static String |
SYSTEM_PROPERTY_SKIP_CONSTANT_POOL
Set this JVM System property to true to skip reading of constant pool entries. |
Fields inherited from class org.gjt.jclasslib.structures.AbstractStructureWithAttributes |
attributes |
Fields inherited from class org.gjt.jclasslib.structures.AbstractStructure |
classFile, debug, SYSTEM_PROPERTY_DEBUG |
Constructor Summary | |
ClassFile()
Constructor. |
Method Summary | |
void |
enlargeConstantPool(CPInfo[] enlargedConstantPool)
Set the array with all constant pool entries where the new array of constant pool entries starts with the old constant pool. |
int |
getAccessFlags()
Get the access flags of this class. |
String |
getAccessFlagsVerbose()
Get the verbose description of the access flags of this class. |
CPInfo[] |
getConstantPool()
Get the array with all constant pool entries. |
CPInfo |
getConstantPoolEntry(int index,
Class entryClass)
Get the constant pool entry at the specified index and cast it to a specified class. |
String |
getConstantPoolEntryName(int index)
Get an approximate verbose description of the content of the constant pool entry at the specified index. |
int |
getConstantPoolIndex(CPInfo cpInfo)
Get the index of an equivalent constant pool entry. |
ConstantUtf8Info |
getConstantPoolUtf8Entry(int index)
Get the ConstantUtf8Info constant pool entry at the specified index. |
FieldInfo |
getField(String name,
String descriptor)
Get the FieldInfo for given field name and signature. |
int |
getFieldIndex(String name,
String descriptor)
Get the index of a field for given field name and signature. |
FieldInfo[] |
getFields()
Get the array with the FieldInfo structures for the fields of this class. |
String |
getFormattedAccessFlags()
Get the the access flags of this class as a hex string. |
int[] |
getInterfaces()
Get the array with the constant pool entries of all interfaces. |
int |
getMajorVersion()
Get the major version of the class file format. |
MethodInfo |
getMethod(String name,
String descriptor)
Get the MethodInfo for given method name and signature. |
int |
getMethodIndex(String name,
String descriptor)
Get the index of a method for given method name and signature. |
MethodInfo[] |
getMethods()
Get the array with the MethodInfo structures for the methods of this class. |
int |
getMinorVersion()
Get the minor version of the class file format. |
int |
getSuperClass()
Get the constant pool index of the super class of this class. |
String |
getSuperClassName()
Get the name of the super class. |
int |
getThisClass()
Get the constant pool index of this class. |
String |
getThisClassName()
Get the name of this class. |
protected String |
printAccessFlagsVerbose(int accessFlags)
Utility method for derived structures. |
void |
read(DataInput in)
Read this structure from the given DataInput. |
protected void |
readAttributes(DataInput in)
Read the attributes of this structure from the given DataInput. |
void |
registerConstantPoolEntry(int index)
Register the constant pool entry at a given index, so that it can be found through the getConstantPoolIndex method. |
void |
setAccessFlags(int accessFlags)
Set the access flags of this class. |
void |
setConstantPool(CPInfo[] constantPool)
Set the array with all constant pool entries. |
void |
setFields(FieldInfo[] fields)
Set the array with the FieldInfo structures for the fields of this class. |
void |
setInterfaces(int[] interfaces)
Set the array with the constant pool entries of all interfaces. |
void |
setMajorVersion(int majorVersion)
Set the major version of the class file format. |
void |
setMethods(MethodInfo[] methods)
Set the array with the MethodInfo structures for the methods of this class. |
void |
setMinorVersion(int minorVersion)
Set the minor version of the class file format. |
void |
setSuperClass(int superClass)
Set the constant pool index of the super class of this class. |
void |
setThisClass(int thisClass)
Set the constant pool index of this class. |
void |
unregisterConstantPoolEntry(int index)
Unregister the constant pool entry at a given index, so that it can no longer be found through the getConstantPoolIndex method. |
void |
write(DataOutput in)
Write this structure to the given DataOutput. |
protected void |
writeAttributes(DataOutput out)
Write the attributes of this structure to the given DataOutput. |
Methods inherited from class org.gjt.jclasslib.structures.AbstractStructureWithAttributes |
findAttribute, getAttributes, getTotalAttributesLength, setAttributes |
Methods inherited from class org.gjt.jclasslib.structures.AbstractStructure |
debug, getClassFile, getDebug, getLength, printAccessFlags, printAccessFlagsVerbose, printBytes, setClassFile, setDebug |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String SYSTEM_PROPERTY_SKIP_CONSTANT_POOL
Constructor Detail |
public ClassFile()
Method Detail |
public int getMinorVersion()
public void setMinorVersion(int minorVersion)
minorVersion
- the minor versionpublic int getMajorVersion()
public void setMajorVersion(int majorVersion)
majorVersion
- the major versionpublic CPInfo[] getConstantPool()
public int getConstantPoolIndex(CPInfo cpInfo)
cpInfo
- the constant pool entry
public void setConstantPool(CPInfo[] constantPool)
constantPool
- the arraypublic void enlargeConstantPool(CPInfo[] enlargedConstantPool)
enlargedConstantPool
- the arraypublic void registerConstantPoolEntry(int index)
index
- the indexpublic void unregisterConstantPoolEntry(int index)
index
- the indexpublic int getAccessFlags()
public void setAccessFlags(int accessFlags)
accessFlags
- the access flagspublic int getThisClass()
public void setThisClass(int thisClass)
thisClass
- the indexpublic String getThisClassName() throws InvalidByteCodeException
InvalidByteCodeException
public int getSuperClass()
public void setSuperClass(int superClass)
superClass
- the indexpublic String getSuperClassName() throws InvalidByteCodeException
InvalidByteCodeException
public int[] getInterfaces()
public void setInterfaces(int[] interfaces)
interfaces
- the arraypublic FieldInfo[] getFields()
public void setFields(FieldInfo[] fields)
fields
- the arraypublic MethodInfo[] getMethods()
public void setMethods(MethodInfo[] methods)
methods
- the arraypublic String getFormattedAccessFlags()
public String getAccessFlagsVerbose()
public ConstantUtf8Info getConstantPoolUtf8Entry(int index) throws InvalidByteCodeException
index
- the index
InvalidByteCodeException
- if the entry is not a ConstantUtf8Infopublic CPInfo getConstantPoolEntry(int index, Class entryClass) throws InvalidByteCodeException
index
- the indexentryClass
- the required subtype of CPInfo
InvalidByteCodeException
- if the entry is of a different class than expectedpublic String getConstantPoolEntryName(int index) throws InvalidByteCodeException
index
- the index
InvalidByteCodeException
- if the entry is invalidpublic int getFieldIndex(String name, String descriptor) throws InvalidByteCodeException
name
- the field name.descriptor
- the signature.
InvalidByteCodeException
public FieldInfo getField(String name, String descriptor) throws InvalidByteCodeException
name
- the field name.descriptor
- the signature.
InvalidByteCodeException
public int getMethodIndex(String name, String descriptor) throws InvalidByteCodeException
name
- the method name.descriptor
- the signature.
InvalidByteCodeException
public MethodInfo getMethod(String name, String descriptor) throws InvalidByteCodeException
name
- the method name.descriptor
- the signature.
InvalidByteCodeException
public void read(DataInput in) throws InvalidByteCodeException, IOException
AbstractStructure
Excpects DataInput to be in JVM class file format and just before a structure of this kind. No look ahead parsing since the class file format is deterministic.
read
in class AbstractStructure
in
- the DataInput from which to read
InvalidByteCodeException
- if the byte code is invalid
IOException
- if an exception occurs with the DataInputpublic void write(DataOutput in) throws InvalidByteCodeException, IOException
AbstractStructure
The written bytes are in JVM class file format.
write
in class AbstractStructure
in
- the DataOutput to which to write
IOException
- if an exception occurs with the DataOutput
InvalidByteCodeException
- if the structure is internally inconsistentprotected void readAttributes(DataInput in) throws InvalidByteCodeException, IOException
AbstractStructureWithAttributes
Excpects DataInput to be in JVM class file format and just before an attribute length field.
readAttributes
in class AbstractStructureWithAttributes
in
- the DataInput from which to read
InvalidByteCodeException
- if the byte code is invalid
IOException
- if an exception occurs with the DataInputprotected void writeAttributes(DataOutput out) throws InvalidByteCodeException, IOException
AbstractStructureWithAttributes
The written bytes are in JVM class file format.
writeAttributes
in class AbstractStructureWithAttributes
out
- the DataOutput to which to write
IOException
- if an exception occurs with the DataOutput
InvalidByteCodeException
- if the structure is internally inconsistentprotected String printAccessFlagsVerbose(int accessFlags)
AbstractStructure
printAccessFlagsVerbose
in class AbstractStructure
accessFlags
- the unsigned short value to print as a hex string
|
ej-technologies | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |