Interface ClassInfo
- All Known Implementing Classes:
ClassFile
public interface ClassInfo
ClassInfo allows a class to be accessed and modified at a very low level.
ClassInfo is implemented by file.ClassFile
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaddNewField(int modifiers, int typeIndex, int nameIndex) Factory method that creates a new field in the class being modeledaddNewField(int modifiers, int typeIndex, int nameIndex, int cvNameIndex, int constantValueIndex) Factory method that creates a new field with a constant value in the class being modeledaddNewMethod(int modifiers, int typeIndex, int nameIndex, int exceptionIndex, int[] exceptionTypeIndices, int codeIndex) Adds a new method to this class.intGet the index into the constant pool of class.voidcommit()Commit any changes to the file or to the virtual machine.voidcommitOnly(Set methods, Set fields) Commits only certain methods and fields.Constant[]Returns an array of the constants in the constant pool.voiddeleteField(int nameIndex) Deletes a field from this classvoiddeleteMethod(int nameIndex, int typeIndex) Deletes a method from this classfields()Get an array of FieldInfo structures for each field in the class.int[]Get the indices into the constant pool of class's interfaces.loader()Get the class info loader for the class.methods()Returns an array of MethodInfo structures for each method in the class.intGet the modifiers of the class.name()Get the name of the class.voidprint(PrintStream out) voidprint(PrintWriter out) voidsetClassIndex(int index) Set the index into the constant pool of class.voidsetConstants(Constant[] constants) Set all the constants in the constant pool.voidsetInterfaceIndices(int[] indices) Set the indices into the constant pool of class's interfaces.voidsetMethods(MethodInfo[] methods) Sets the methods in this class.voidsetModifiers(int modifiers) Set the modifiers of the class.voidsetSuperclassIndex(int index) Set the index into the constant pool of class's superclass.intGet the index into the constant pool of class's superclass.toString()
-
Method Details
-
loader
-
name
-
classIndex
int classIndex()Get the index into the constant pool of class.- Returns:
- The index of the class.
-
superclassIndex
int superclassIndex()Get the index into the constant pool of class's superclass.- Returns:
- The index of the superclass.
-
interfaceIndices
int[] interfaceIndices()Get the indices into the constant pool of class's interfaces.- Returns:
- The indices of the interfaces.
-
setClassIndex
void setClassIndex(int index) Set the index into the constant pool of class.- Parameters:
index- The index of the class.
-
setSuperclassIndex
void setSuperclassIndex(int index) Set the index into the constant pool of class's superclass.- Parameters:
index- The index of the superclass.
-
setInterfaceIndices
void setInterfaceIndices(int[] indices) Set the indices into the constant pool of class's interfaces.- Parameters:
indices- The indices of the interfaces.
-
setModifiers
void setModifiers(int modifiers) Set the modifiers of the class. The values correspond to the constants in the Modifiers class.- Parameters:
modifiers- A bit vector of modifier flags for the class.- See Also:
-
modifiers
int modifiers()Get the modifiers of the class. The values correspond to the constants in the Modifiers class.- Returns:
- A bit vector of modifier flags for the class.
- See Also:
-
fields
FieldInfo[] fields()Get an array of FieldInfo structures for each field in the class.- Returns:
- An array of FieldInfo structures.
- See Also:
-
methods
MethodInfo[] methods()Returns an array of MethodInfo structures for each method in the class. -
setMethods
Sets the methods in this class. -
constants
Constant[] constants()Returns an array of the constants in the constant pool. -
setConstants
Set all the constants in the constant pool.- Parameters:
constants- The array of Constants.- See Also:
-
commit
void commit()Commit any changes to the file or to the virtual machine. -
commitOnly
-
addNewField
Factory method that creates a new field in the class being modeled -
addNewField
FieldInfo addNewField(int modifiers, int typeIndex, int nameIndex, int cvNameIndex, int constantValueIndex) Factory method that creates a new field with a constant value in the class being modeled- Parameters:
cvNameIndex- The index in the class's constant pool for the UTF8 constant "ConstantValue"constantValueIndex- The index in the class's constant pool for the constant value
-
deleteField
void deleteField(int nameIndex) Deletes a field from this class- Parameters:
nameIndex- Index in the constant pool of the name of the field to be deleted- Throws:
IllegalArgumentException- The class modeled by thisClassInfodoes not contain a field whose name is at the given index
-
deleteMethod
void deleteMethod(int nameIndex, int typeIndex) Deletes a method from this class- Parameters:
nameIndex- Index in the constant pool of the name of the method to be deletedtypeIndex- Index in the constant pool of the type of the method to be deleted- Throws:
IllegalArgumentException- The class modeled by thisClassInfodoes not contain a method whose name and type are not at the given indices
-
addNewMethod
MethodInfo addNewMethod(int modifiers, int typeIndex, int nameIndex, int exceptionIndex, int[] exceptionTypeIndices, int codeIndex) Adds a new method to this class.- Parameters:
modifiers- Themodifiersfor the new methodtypeIndex- The index of the type (conglomeration of the parameter types and the return type) for this method in the class's constant poolnameIndex- The index of the name of the method in the class's constant poolexceptionIndex- The index of the UTF8 string "Exceptions" in the class's constant poolexceptionTypeIndices- The indices in the class's constant pool of the type of the exceptions thrown by this methodcodeIndex- The index of the UTF8 string "Code" in the class's constant pool
-
print
-
print
-
toString
-