public class CodeAttributeComposer extends SimplifiedVisitor implements AttributeVisitor, InstructionVisitor, ExceptionInfoVisitor, StackMapFrameVisitor, VerificationTypeVisitor, LineNumberInfoVisitor, LocalVariableInfoVisitor, LocalVariableTypeInfoVisitor
| Constructor and Description |
|---|
CodeAttributeComposer()
Creates a new CodeAttributeComposer that doesn't allow external branch
targets or exception handlers and that automatically shrinks
instructions.
|
CodeAttributeComposer(boolean allowExternalBranchTargets,
boolean allowExternalExceptionHandlers,
boolean shrinkInstructions)
Creates a new CodeAttributeComposer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendException(ExceptionInfo exceptionInfo)
Appends the given exception to the exception table.
|
void |
appendInstruction(Instruction instruction)
Appends the given instruction without a defined offset.
|
void |
appendInstruction(int oldInstructionOffset,
Instruction instruction)
Appends the given instruction with the given old offset.
|
void |
appendInstructions(Instruction[] instructions)
Appends the given instruction without defined offsets.
|
void |
appendLabel(int oldInstructionOffset)
Appends the given label with the given old offset.
|
void |
appendLineNumber(LineNumberInfo lineNumberInfo)
Appends the given line number to the line number table.
|
void |
beginCodeFragment(int maximumCodeFragmentLength)
Starts a new code fragment.
|
void |
endCodeFragment()
Wraps up the current code fragment, continuing with the previous one on
the stack.
|
int |
insertLineNumber(int minimumIndex,
LineNumberInfo lineNumberInfo)
Inserts the given line number at the appropriate position in the line
number table.
|
int |
insertLineNumber(LineNumberInfo lineNumberInfo)
Inserts the given line number at the appropriate position in the line
number table.
|
static void |
main(String[] args) |
void |
reset()
Starts a new code definition.
|
void |
visitAnyAttribute(Clazz clazz,
Attribute attribute)
Visit any type of attribute.
|
void |
visitAnyInstruction(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
Instruction instruction)
Visits any type of Instruction.
|
void |
visitAnyStackMapFrame(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
StackMapFrame stackMapFrame)
Visits any type of VerificationType.
|
void |
visitAnySwitchInstruction(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
SwitchInstruction switchInstruction)
Visits either type of SwitchInstruction.
|
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 |
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 |
visitLocalVariableTypeInfo(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
LocalVariableTypeInfo localVariableTypeInfo) |
void |
visitLocalVariableTypeTableAttribute(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
LocalVariableTypeTableAttribute localVariableTypeTableAttribute) |
void |
visitMoreZeroFrame(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
MoreZeroFrame moreZeroFrame) |
void |
visitSameOneFrame(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
SameOneFrame sameOneFrame) |
void |
visitStackMapAttribute(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
StackMapAttribute stackMapAttribute) |
void |
visitStackMapTableAttribute(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
StackMapTableAttribute stackMapTableAttribute) |
void |
visitUninitializedType(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
int offset,
UninitializedType uninitializedType) |
visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotationDefaultAttribute, visitAnnotationElementValue, visitAnyAnnotationsAttribute, visitAnyClass, visitAnyConstant, visitAnyElementValue, visitAnyMember, visitAnyMethodrefConstant, visitAnyParameterAnnotationsAttribute, visitAnyRefConstant, visitAnyTargetInfo, visitAnyTypeAnnotationsAttribute, visitArrayElementValue, visitBootstrapMethodsAttribute, visitCatchTargetInfo, visitClassConstant, visitClassElementValue, visitConstantElementValue, visitConstantInstruction, 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, visitLocalVariableTargetInfo, visitLongConstant, visitLongType, visitLookUpSwitchInstruction, visitMethodHandleConstant, visitMethodParametersAttribute, visitMethodrefConstant, visitMethodTypeConstant, visitNameAndTypeConstant, visitNullType, visitObjectType, visitOffsetTargetInfo, 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, visitSimpleInstruction, visitSourceDirAttribute, visitSourceFileAttribute, visitStackDoubleType, visitStackFloatType, visitStackIntegerType, visitStackLongType, visitStackNullType, visitStackObjectType, visitStackTopType, visitStackUninitializedThisType, visitStackUninitializedType, visitStringConstant, visitSuperTypeTargetInfo, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitTableSwitchInstruction, visitThrowsTargetInfo, visitTopType, visitTypeAnnotation, visitTypeAnnotation, visitTypeAnnotation, visitTypeAnnotation, visitTypeAnnotation, visitTypeAnnotation, visitTypeArgumentTargetInfo, visitTypeParameterBoundTargetInfo, visitTypeParameterBoundTargetInfo, visitTypeParameterBoundTargetInfo, visitTypeParameterBoundTargetInfo, visitTypeParameterTargetInfo, visitTypeParameterTargetInfo, visitTypePathInfo, visitTypePathInfo, visitTypePathInfo, visitTypePathInfo, visitTypePathInfo, visitUninitializedThisType, visitUnknownAttribute, visitUtf8Constant, visitVariableInstruction, 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, visitUnknownAttributevisitConstantInstruction, visitLookUpSwitchInstruction, visitSimpleInstruction, visitTableSwitchInstruction, visitVariableInstructionvisitLessZeroFrame, 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, visitVariablesUninitializedTypepublic CodeAttributeComposer()
public CodeAttributeComposer(boolean allowExternalBranchTargets,
boolean allowExternalExceptionHandlers,
boolean shrinkInstructions)
allowExternalBranchTargets - specifies whether branch targets
can lie outside the code fragment
of the branch instructions.allowExternalExceptionHandlers - specifies whether exception
handlers can lie outside the code
fragment in which exceptions are
defined.shrinkInstructions - specifies whether instructions
should automatically be shrunk
before being written.public void reset()
public void beginCodeFragment(int maximumCodeFragmentLength)
maximumCodeFragmentLength - the maximum length of the code that will
be added as part of this fragment (more
precisely, the maximum old instruction
offset or label that is specified, plus
one).public void appendInstruction(int oldInstructionOffset,
Instruction instruction)
oldInstructionOffset - the old offset of the instruction, to which
branches and other references in the current
code fragment are pointing.instruction - the instruction to be appended.public void appendLabel(int oldInstructionOffset)
oldInstructionOffset - the old offset of the label, to which
branches and other references in the current
code fragment are pointing.public void appendInstructions(Instruction[] instructions)
instructions - the instructions to be appended.public void appendInstruction(Instruction instruction)
instruction - the instruction to be appended.public void appendException(ExceptionInfo exceptionInfo)
exceptionInfo - the exception to be appended.public int insertLineNumber(LineNumberInfo lineNumberInfo)
lineNumberInfo - the line number to be inserted.public int insertLineNumber(int minimumIndex,
LineNumberInfo lineNumberInfo)
minimumIndex - the minimum index where the line number may be
inserted.lineNumberInfo - the line number to be inserted.public void appendLineNumber(LineNumberInfo lineNumberInfo)
lineNumberInfo - the line number to be appended.public void endCodeFragment()
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 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 visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction)
SimplifiedVisitorvisitAnyInstruction in class SimplifiedVisitorpublic void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
visitBranchInstruction in interface InstructionVisitorvisitBranchInstruction in class SimplifiedVisitorpublic void visitAnySwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SwitchInstruction switchInstruction)
SimplifiedVisitorvisitAnySwitchInstruction 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 static void main(String[] args)
Copyright © 2015. All Rights Reserved.