-
- All Implemented Interfaces:
-
org.gjt.jclasslib.structures.AttributeContainer
public final class ClassFile extends Structure implements AttributeContainer
The class file structure in which all other structures are hooked up.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classClassFile.Companion
-
Field Summary
Fields Modifier and Type Field Description private IntegerminorVersionprivate IntegermajorVersionprivate Array<Constant>constantPoolprivate IntegeraccessFlagsprivate IntegerthisClassprivate final ConstantClassInfothisClassConstantprivate IntegersuperClassprivate final ConstantClassInfosuperClassConstantprivate IntArrayinterfacesprivate Array<FieldInfo>fieldsprivate Array<MethodInfo>methodsprivate Array<AttributeInfo>attributesprivate final StringmajorVersionVerboseprivate final StringthisClassNameprivate final StringsimpleClassNameprivate final StringsuperClassNameprivate final StringformattedAccessFlagsprivate final StringaccessFlagsVerboseprivate final IntegertotalAttributesLength
-
Constructor Summary
Constructors Constructor Description ClassFile()
-
Method Summary
Modifier and Type Method Description final IntegergetMinorVersion()Minor version of the class file format. final UnitsetMinorVersion(Integer minorVersion)Minor version of the class file format. final IntegergetMajorVersion()Major version of the class file format. final UnitsetMajorVersion(Integer majorVersion)Major version of the class file format. final Array<Constant>getConstantPool()Constant pool entries. final UnitsetConstantPool(Array<Constant> constantPool)final IntegergetAccessFlags()Access flags of this class. final UnitsetAccessFlags(Integer accessFlags)Access flags of this class. final IntegergetThisClass()Constant pool index of this class. final UnitsetThisClass(Integer thisClass)Constant pool index of this class. final ConstantClassInfogetThisClassConstant()final IntegergetSuperClass()Constant pool index of the super class of this class. final UnitsetSuperClass(Integer superClass)Constant pool index of the super class of this class. final ConstantClassInfogetSuperClassConstant()final IntArraygetInterfaces()Constant pool entries of all interfaces. final UnitsetInterfaces(IntArray interfaces)Constant pool entries of all interfaces. final Array<FieldInfo>getFields()FieldInfo structures for the fields of this class. final UnitsetFields(Array<FieldInfo> fields)FieldInfo structures for the fields of this class. final Array<MethodInfo>getMethods()MethodInfo structures for the methods of this class. final UnitsetMethods(Array<MethodInfo> methods)MethodInfo structures for the methods of this class. Array<AttributeInfo>getAttributes()Attributes of this structure. UnitsetAttributes(Array<AttributeInfo> attributes)Attributes of this structure. final StringgetMajorVersionVerbose()final StringgetThisClassName()final StringgetSimpleClassName()final StringgetSuperClassName()final StringgetFormattedAccessFlags()final StringgetAccessFlagsVerbose()final IntegergetConstantPoolIndex(Constant constant)Index of an equivalent constant pool entry, or -1 if no equivalent constant pool entry can be found. final UnitenlargeConstantPool(Array<Constant> enlargedConstantPool)Set all constant pool entries where the new array of constant pool entries must start with the old constant pool. final UnitregisterConstantPoolEntry(Integer index)Register the constant pool entry at a given index, so that it can be found through the getConstantPoolIndex method. final UnitunregisterConstantPoolEntry(Integer index)Unregister the constant pool entry at a given index, so that it can no longer be found through the getConstantPoolIndex method. final ConstantUtf8InfogetConstantPoolUtf8Entry(Integer index)The ConstantUtf8Info constant pool entry at the specified index. final <T extends Constant> TgetConstantPoolEntry(Integer index, Class<T> entryClass)Get the constant pool entry at the specified index and cast it to a specified class. final StringgetConstantPoolEntryName(Integer index)Get an approximate verbose description of the content of the constant pool entry at the specified index. final IntegergetFieldIndex(String name, String descriptor)Get the index of a field for given field name and signature or -1 if not found. final FieldInfogetField(String name, String descriptor)Get the FieldInfo for given field name and signature or null if not found. final IntegergetMethodIndex(String name, String descriptor)Get the index of a method for given method name and signature or -1 if not found. final MethodInfogetMethod(String name, String descriptor)Get the MethodInfo for given method name and signature or null if not found. -
Methods inherited from class org.gjt.jclasslib.structures.AttributeContainer
findAttribute, getTotalAttributesLength, readAttributes, writeAttributes -
Methods inherited from class org.gjt.jclasslib.structures.Structure
read, write -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getMinorVersion
final Integer getMinorVersion()
Minor version of the class file format.
-
setMinorVersion
final Unit setMinorVersion(Integer minorVersion)
Minor version of the class file format.
-
getMajorVersion
final Integer getMajorVersion()
Major version of the class file format.
-
setMajorVersion
final Unit setMajorVersion(Integer majorVersion)
Major version of the class file format.
-
getConstantPool
final Array<Constant> getConstantPool()
Constant pool entries.
-
setConstantPool
final Unit setConstantPool(Array<Constant> constantPool)
-
getAccessFlags
final Integer getAccessFlags()
Access flags of this class.
-
setAccessFlags
final Unit setAccessFlags(Integer accessFlags)
Access flags of this class.
-
getThisClass
final Integer getThisClass()
Constant pool index of this class.
-
setThisClass
final Unit setThisClass(Integer thisClass)
Constant pool index of this class.
-
getThisClassConstant
final ConstantClassInfo getThisClassConstant()
-
getSuperClass
final Integer getSuperClass()
Constant pool index of the super class of this class.
-
setSuperClass
final Unit setSuperClass(Integer superClass)
Constant pool index of the super class of this class.
-
getSuperClassConstant
final ConstantClassInfo getSuperClassConstant()
-
getInterfaces
final IntArray getInterfaces()
Constant pool entries of all interfaces.
-
setInterfaces
final Unit setInterfaces(IntArray interfaces)
Constant pool entries of all interfaces.
-
setFields
final Unit setFields(Array<FieldInfo> fields)
FieldInfo structures for the fields of this class.
-
getMethods
final Array<MethodInfo> getMethods()
MethodInfo structures for the methods of this class.
-
setMethods
final Unit setMethods(Array<MethodInfo> methods)
MethodInfo structures for the methods of this class.
-
getAttributes
Array<AttributeInfo> getAttributes()
Attributes of this structure.
-
setAttributes
Unit setAttributes(Array<AttributeInfo> attributes)
Attributes of this structure.
-
getMajorVersionVerbose
final String getMajorVersionVerbose()
-
getThisClassName
final String getThisClassName()
-
getSimpleClassName
final String getSimpleClassName()
-
getSuperClassName
final String getSuperClassName()
-
getFormattedAccessFlags
final String getFormattedAccessFlags()
-
getAccessFlagsVerbose
final String getAccessFlagsVerbose()
-
getConstantPoolIndex
final Integer getConstantPoolIndex(Constant constant)
Index of an equivalent constant pool entry, or -1 if no equivalent constant pool entry can be found.
- Parameters:
constant- the constant pool entry
-
enlargeConstantPool
final Unit enlargeConstantPool(Array<Constant> enlargedConstantPool)
Set all constant pool entries where the new array of constant pool entries must start with the old constant pool. If you delete entries, use setConstantPool.
- Parameters:
enlargedConstantPool- the enlarged constant pool
-
registerConstantPoolEntry
final Unit registerConstantPoolEntry(Integer index)
Register the constant pool entry at a given index, so that it can be found through the getConstantPoolIndex method.
- Parameters:
index- the index
-
unregisterConstantPoolEntry
final Unit unregisterConstantPoolEntry(Integer index)
Unregister the constant pool entry at a given index, so that it can no longer be found through the getConstantPoolIndex method.
- Parameters:
index- the index
-
getConstantPoolUtf8Entry
final ConstantUtf8Info getConstantPoolUtf8Entry(Integer index)
The ConstantUtf8Info constant pool entry at the specified index.
- Parameters:
index- the index
-
getConstantPoolEntry
final <T extends Constant> T getConstantPoolEntry(Integer index, Class<T> entryClass)
Get the constant pool entry at the specified index and cast it to a specified class.
- Parameters:
index- the indexentryClass- the required subtype of CPInfo
-
getConstantPoolEntryName
final String getConstantPoolEntryName(Integer index)
Get an approximate verbose description of the content of the constant pool entry at the specified index.
- Parameters:
index- the index
-
getFieldIndex
final Integer getFieldIndex(String name, String descriptor)
Get the index of a field for given field name and signature or -1 if not found.
- Parameters:
name- the field name.descriptor- the signature.
-
getField
final FieldInfo getField(String name, String descriptor)
Get the FieldInfo for given field name and signature or null if not found.
- Parameters:
name- the field name.descriptor- the signature.
-
getMethodIndex
final Integer getMethodIndex(String name, String descriptor)
Get the index of a method for given method name and signature or -1 if not found.
- Parameters:
name- the method name.descriptor- the signature.
-
getMethod
final MethodInfo getMethod(String name, String descriptor)
Get the MethodInfo for given method name and signature or null if not found.
- Parameters:
name- the method name.descriptor- the signature.
-
-
-
-