public class CodeAttributeEditor extends SimplifiedVisitor implements AttributeVisitor, InstructionVisitor, ExceptionInfoVisitor, StackMapFrameVisitor, VerificationTypeVisitor, LineNumberInfoVisitor, LocalVariableInfoVisitor, LocalVariableTypeInfoVisitor, TypeAnnotationVisitor, TargetInfoVisitor, LocalVariableTargetElementVisitor
| Modifier and Type | Field and Description |
|---|---|
boolean[] |
deleted |
Instruction[] |
postInsertions |
Instruction[] |
preInsertions |
Instruction[] |
replacements |
| Constructor and Description |
|---|
CodeAttributeEditor()
Creates a new CodeAttributeEditor that automatically updates frame
sizes and shrinks instructions.
|
CodeAttributeEditor(boolean updateFrameSizes,
boolean shrinkInstructions)
Creates a new CodeAttributeEditor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearModifications(int instructionOffset)
Clears all modifications of the instruction at the given offset.
|
void |
deleteInstruction(int instructionOffset)
Remembers to delete the instruction at the given offset.
|
void |
extend(int codeLength)
Extends the size of the accumulated code changes.
|
void |
insertAfterInstruction(int instructionOffset,
Instruction instruction)
Remembers to place the given instruction right after the instruction
at the given offset.
|
void |
insertAfterInstruction(int instructionOffset,
Instruction[] instructions)
Remembers to place the given instructions right after the instruction
at the given offset.
|
void |
insertBeforeInstruction(int instructionOffset,
Instruction instruction)
Remembers to place the given instruction right before the instruction
at the given offset.
|
void |
insertBeforeInstruction(int instructionOffset,
Instruction[] instructions)
Remembers to place the given instructions right before the instruction
at the given offset.
|
boolean |
isModified()
Returns whether the code has been modified in any way.
|
boolean |
isModified(int instructionOffset)
Returns whether the instruction at the given offset has been modified
in any way.
|
void |
replaceInstruction(int instructionOffset,
Instruction instruction)
Remembers to replace the instruction at the given offset by the given
instruction.
|
void |
replaceInstruction(int instructionOffset,
Instruction[] instructions)
Remembers to replace the instruction at the given offset by the given
instructions.
|
void |
reset(int codeLength)
Resets the accumulated code changes.
|
void |
undeleteInstruction(int instructionOffset)
Remembers not to delete the instruction at the given offset.
|
void |
visitAnyAttribute(Clazz clazz,
Attribute attribute)
Visit any type of attribute.
|
void |
visitAnyStackMapFrame(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
StackMapFrame stackMapFrame)
Visits any type of VerificationType.
|
void |
visitAnyTargetInfo(Clazz clazz,
TypeAnnotation typeAnnotation,
TargetInfo targetInfo)
Visits any type of TargetInfo.
|
void |
visitAnyTypeAnnotationsAttribute(Clazz clazz,
TypeAnnotationsAttribute typeAnnotationsAttribute)
Visits any type of TypeAnnotationsAttribute of a class.
|
void |
visitAnyVerificationType(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
VerificationType verificationType)
Visits any type of VerificationType.
|
void |
visitBranchInstruction(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
BranchInstruction branchInstruction) |
void |
visitCodeAttribute(Clazz clazz,
Method method,
CodeAttribute codeAttribute) |
void |
visitCodeAttribute0(Clazz clazz,
Method method,
CodeAttribute codeAttribute) |
void |
visitConstantInstruction(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
ConstantInstruction constantInstruction) |
void |
visitExceptionInfo(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
ExceptionInfo exceptionInfo) |
void |
visitFullFrame(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
FullFrame fullFrame) |
void |
visitLineNumberInfo(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
LineNumberInfo lineNumberInfo) |
void |
visitLineNumberTableAttribute(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
LineNumberTableAttribute lineNumberTableAttribute) |
void |
visitLocalVariableInfo(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
LocalVariableInfo localVariableInfo) |
void |
visitLocalVariableTableAttribute(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
LocalVariableTableAttribute localVariableTableAttribute) |
void |
visitLocalVariableTargetElement(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
TypeAnnotation typeAnnotation,
LocalVariableTargetInfo localVariableTargetInfo,
LocalVariableTargetElement localVariableTargetElement) |
void |
visitLocalVariableTargetInfo(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
TypeAnnotation typeAnnotation,
LocalVariableTargetInfo localVariableTargetInfo) |
void |
visitLocalVariableTypeInfo(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
LocalVariableTypeInfo localVariableTypeInfo) |
void |
visitLocalVariableTypeTableAttribute(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
LocalVariableTypeTableAttribute localVariableTypeTableAttribute) |
void |
visitLookUpSwitchInstruction(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
LookUpSwitchInstruction lookUpSwitchInstruction) |
void |
visitMoreZeroFrame(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
MoreZeroFrame moreZeroFrame) |
void |
visitOffsetTargetInfo(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
TypeAnnotation typeAnnotation,
OffsetTargetInfo offsetTargetInfo) |
void |
visitSameOneFrame(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
SameOneFrame sameOneFrame) |
void |
visitSimpleInstruction(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
SimpleInstruction simpleInstruction) |
void |
visitStackMapAttribute(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
StackMapAttribute stackMapAttribute) |
void |
visitStackMapTableAttribute(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
StackMapTableAttribute stackMapTableAttribute) |
void |
visitTableSwitchInstruction(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
TableSwitchInstruction tableSwitchInstruction) |
void |
visitTypeAnnotation(Clazz clazz,
TypeAnnotation typeAnnotation) |
void |
visitUninitializedType(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
UninitializedType uninitializedType) |
void |
visitVariableInstruction(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
VariableInstruction variableInstruction) |
visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotationDefaultAttribute, visitAnnotationElementValue, visitAnyAnnotationsAttribute, visitAnyClass, visitAnyConstant, visitAnyElementValue, visitAnyInstruction, visitAnyMember, visitAnyMethodrefConstant, visitAnyParameterAnnotationsAttribute, visitAnyRefConstant, visitAnySwitchInstruction, visitArrayElementValue, visitBootstrapMethodsAttribute, visitCatchTargetInfo, visitClassConstant, visitClassElementValue, visitConstantElementValue, visitConstantValueAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDoubleConstant, visitDoubleType, visitEmptyTargetInfo, visitEmptyTargetInfo, visitEmptyTargetInfo, visitEnclosingMethodAttribute, visitEnumConstantElementValue, visitExceptionsAttribute, visitFieldrefConstant, visitFloatConstant, visitFloatType, visitFormalParameterTargetInfo, visitInnerClassesAttribute, visitIntegerConstant, visitIntegerType, visitInterfaceMethodrefConstant, visitInvokeDynamicConstant, visitLessZeroFrame, visitLibraryClass, visitLibraryField, visitLibraryMember, visitLibraryMethod, visitLongConstant, visitLongType, visitMethodHandleConstant, visitMethodParametersAttribute, visitMethodrefConstant, visitMethodTypeConstant, visitNameAndTypeConstant, visitNullType, visitObjectType, visitProgramClass, visitProgramField, visitProgramMember, visitProgramMethod, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleParameterAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleParameterAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitSameZeroFrame, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSourceDirAttribute, visitSourceFileAttribute, visitStackDoubleType, visitStackFloatType, visitStackIntegerType, visitStackLongType, visitStackNullType, visitStackObjectType, visitStackTopType, visitStackUninitializedThisType, visitStackUninitializedType, visitStringConstant, visitSuperTypeTargetInfo, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitThrowsTargetInfo, visitTopType, visitTypeAnnotation, visitTypeAnnotation, visitTypeAnnotation, visitTypeAnnotation, visitTypeAnnotation, visitTypeArgumentTargetInfo, visitTypeParameterBoundTargetInfo, visitTypeParameterBoundTargetInfo, visitTypeParameterBoundTargetInfo, visitTypeParameterBoundTargetInfo, visitTypeParameterTargetInfo, visitTypeParameterTargetInfo, visitTypePathInfo, visitTypePathInfo, visitTypePathInfo, visitTypePathInfo, visitTypePathInfo, visitUninitializedThisType, visitUnknownAttribute, visitUtf8Constant, visitVariablesDoubleType, visitVariablesFloatType, visitVariablesIntegerType, visitVariablesLongType, visitVariablesNullType, visitVariablesObjectType, visitVariablesTopType, visitVariablesUninitializedThisType, visitVariablesUninitializedTypeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitvisitAnnotationDefaultAttribute, visitBootstrapMethodsAttribute, visitConstantValueAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitEnclosingMethodAttribute, visitExceptionsAttribute, visitInnerClassesAttribute, visitMethodParametersAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleParameterAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleParameterAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSourceDirAttribute, visitSourceFileAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitUnknownAttributevisitLessZeroFrame, visitSameZeroFramevisitDoubleType, visitFloatType, visitIntegerType, visitLongType, visitNullType, visitObjectType, visitStackDoubleType, visitStackFloatType, visitStackIntegerType, visitStackLongType, visitStackNullType, visitStackObjectType, visitStackTopType, visitStackUninitializedThisType, visitStackUninitializedType, visitTopType, visitUninitializedThisType, visitVariablesDoubleType, visitVariablesFloatType, visitVariablesIntegerType, visitVariablesLongType, visitVariablesNullType, visitVariablesObjectType, visitVariablesTopType, visitVariablesUninitializedThisType, visitVariablesUninitializedTypevisitTypeAnnotation, visitTypeAnnotation, visitTypeAnnotationvisitCatchTargetInfo, visitEmptyTargetInfo, visitEmptyTargetInfo, visitFormalParameterTargetInfo, visitSuperTypeTargetInfo, visitThrowsTargetInfo, visitTypeArgumentTargetInfo, visitTypeParameterBoundTargetInfo, visitTypeParameterBoundTargetInfo, visitTypeParameterBoundTargetInfo, visitTypeParameterTargetInfo, visitTypeParameterTargetInfopublic Instruction[] preInsertions
public Instruction[] replacements
public Instruction[] postInsertions
public boolean[] deleted
public CodeAttributeEditor()
public CodeAttributeEditor(boolean updateFrameSizes,
boolean shrinkInstructions)
updateFrameSizes - specifies whether frame sizes of edited code
should be updated.shrinkInstructions - specifies whether added instructions should
automatically be shrunk before being written.public void reset(int codeLength)
codeLength - the length of the code that will be edited next.public void extend(int codeLength)
codeLength - the length of the code that will be edited next.public void insertBeforeInstruction(int instructionOffset,
Instruction instruction)
instructionOffset - the offset of the instruction.instruction - the new instruction.public void insertBeforeInstruction(int instructionOffset,
Instruction[] instructions)
instructionOffset - the offset of the instruction.instructions - the new instructions.public void replaceInstruction(int instructionOffset,
Instruction instruction)
instructionOffset - the offset of the instruction to be replaced.instruction - the new instruction.public void replaceInstruction(int instructionOffset,
Instruction[] instructions)
instructionOffset - the offset of the instruction to be replaced.instructions - the new instructions.public void insertAfterInstruction(int instructionOffset,
Instruction instruction)
instructionOffset - the offset of the instruction.instruction - the new instruction.public void insertAfterInstruction(int instructionOffset,
Instruction[] instructions)
instructionOffset - the offset of the instruction.instructions - the new instructions.public void deleteInstruction(int instructionOffset)
instructionOffset - the offset of the instruction to be deleted.public void undeleteInstruction(int instructionOffset)
instructionOffset - the offset of the instruction not to be deleted.public void clearModifications(int instructionOffset)
instructionOffset - the offset of the instruction to be deleted.public boolean isModified()
public boolean isModified(int instructionOffset)
public void visitAnyAttribute(Clazz clazz, Attribute attribute)
SimplifiedVisitorvisitAnyAttribute in class SimplifiedVisitorpublic void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
visitCodeAttribute in interface AttributeVisitorvisitCodeAttribute in class SimplifiedVisitorpublic void visitCodeAttribute0(Clazz clazz, Method method, CodeAttribute codeAttribute)
public void visitStackMapAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapAttribute stackMapAttribute)
visitStackMapAttribute in interface AttributeVisitorvisitStackMapAttribute in class SimplifiedVisitorpublic void visitStackMapTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapTableAttribute stackMapTableAttribute)
visitStackMapTableAttribute in interface AttributeVisitorvisitStackMapTableAttribute in class SimplifiedVisitorpublic void visitLineNumberTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberTableAttribute lineNumberTableAttribute)
visitLineNumberTableAttribute in interface AttributeVisitorvisitLineNumberTableAttribute in class SimplifiedVisitorpublic void visitLocalVariableTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTableAttribute localVariableTableAttribute)
visitLocalVariableTableAttribute in interface AttributeVisitorvisitLocalVariableTableAttribute in class SimplifiedVisitorpublic void visitLocalVariableTypeTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeTableAttribute localVariableTypeTableAttribute)
visitLocalVariableTypeTableAttribute in interface AttributeVisitorvisitLocalVariableTypeTableAttribute in class SimplifiedVisitorpublic void visitAnyTypeAnnotationsAttribute(Clazz clazz, TypeAnnotationsAttribute typeAnnotationsAttribute)
SimplifiedVisitorvisitAnyTypeAnnotationsAttribute in class SimplifiedVisitorpublic void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)
visitSimpleInstruction in interface InstructionVisitorvisitSimpleInstruction in class SimplifiedVisitorpublic void visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction)
visitConstantInstruction in interface InstructionVisitorvisitConstantInstruction in class SimplifiedVisitorpublic void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction)
visitVariableInstruction in interface InstructionVisitorvisitVariableInstruction in class SimplifiedVisitorpublic void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
visitBranchInstruction in interface InstructionVisitorvisitBranchInstruction in class SimplifiedVisitorpublic void visitTableSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, TableSwitchInstruction tableSwitchInstruction)
visitTableSwitchInstruction in interface InstructionVisitorvisitTableSwitchInstruction in class SimplifiedVisitorpublic void visitLookUpSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, LookUpSwitchInstruction lookUpSwitchInstruction)
visitLookUpSwitchInstruction in interface InstructionVisitorvisitLookUpSwitchInstruction in class SimplifiedVisitorpublic void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo)
visitExceptionInfo in interface ExceptionInfoVisitorpublic void visitAnyStackMapFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, StackMapFrame stackMapFrame)
SimplifiedVisitorvisitAnyStackMapFrame in class SimplifiedVisitorpublic void visitSameOneFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SameOneFrame sameOneFrame)
visitSameOneFrame in interface StackMapFrameVisitorvisitSameOneFrame in class SimplifiedVisitorpublic void visitMoreZeroFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, MoreZeroFrame moreZeroFrame)
visitMoreZeroFrame in interface StackMapFrameVisitorvisitMoreZeroFrame in class SimplifiedVisitorpublic void visitFullFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, FullFrame fullFrame)
visitFullFrame in interface StackMapFrameVisitorvisitFullFrame in class SimplifiedVisitorpublic void visitAnyVerificationType(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VerificationType verificationType)
SimplifiedVisitorvisitAnyVerificationType in class SimplifiedVisitorpublic void visitUninitializedType(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, UninitializedType uninitializedType)
visitUninitializedType in interface VerificationTypeVisitorvisitUninitializedType in class SimplifiedVisitorpublic void visitLineNumberInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberInfo lineNumberInfo)
visitLineNumberInfo in interface LineNumberInfoVisitorpublic void visitLocalVariableInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableInfo localVariableInfo)
visitLocalVariableInfo in interface LocalVariableInfoVisitorpublic void visitLocalVariableTypeInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeInfo localVariableTypeInfo)
visitLocalVariableTypeInfo in interface LocalVariableTypeInfoVisitorpublic void visitTypeAnnotation(Clazz clazz, TypeAnnotation typeAnnotation)
visitTypeAnnotation in interface TypeAnnotationVisitorvisitTypeAnnotation in class SimplifiedVisitorpublic void visitAnyTargetInfo(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfo targetInfo)
SimplifiedVisitorvisitAnyTargetInfo in class SimplifiedVisitorpublic void visitLocalVariableTargetInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, LocalVariableTargetInfo localVariableTargetInfo)
visitLocalVariableTargetInfo in interface TargetInfoVisitorvisitLocalVariableTargetInfo in class SimplifiedVisitorpublic void visitOffsetTargetInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, OffsetTargetInfo offsetTargetInfo)
visitOffsetTargetInfo in interface TargetInfoVisitorvisitOffsetTargetInfo in class SimplifiedVisitorpublic void visitLocalVariableTargetElement(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, LocalVariableTargetInfo localVariableTargetInfo, LocalVariableTargetElement localVariableTargetElement)
visitLocalVariableTargetElement in interface LocalVariableTargetElementVisitorCopyright © 2015. All Rights Reserved.