public class CompactCodeAttributeComposer extends java.lang.Object implements AttributeVisitor
AttributeVisitor
accumulates instructions, exceptions and line numbers,
in a compact and fluent style, and then adds them to a method or copies them into
code attributes that it visits.
The class supports composing
instructions (appendInstruction(Instruction)
),
labels (createLabel()
and label(Label)
),
exception handlers (catch_(Label, Label, String, Clazz)
), and
line numbers (line(int)
).
The labels are numeric labels that you can choose freely, for example
instruction offsets from existing code that you are copying. You can then
refer to them in branches and exception handlers. You can compose the
code as a hierarchy of code fragments with their own local labels.
You should provide an estimated maximum size (expressed in number of
bytes in the bytecode), so the implementation can efficiently allocate
the necessary internal buffers without reallocating them as the code
grows.
For example:
ProgramClass programClass = ... ProgramMethod programMethod = ... // Compose the code. CompactCodeAttributeComposer composer = new CompactCodeAttributeComposer(programClass); final Label TRY_START = composer.createLabel(); final Label TRY_END = composer.createLabel(); final Label ELSE = composer.createLabel(); composer .beginCodeFragment(50) .label(TRY_START) .iconst_1() .iconst_2() .ificmplt(ELSE) .iconst_1() .ireturn() .label(ELSE) .iconst_2() .ireturn() .label(TRY_END) .catch_(TRY_START, TRY_END, "java/lang/Exception", null) .iconst_m1() .ireturn() .endCodeFragment(); // Add the code as a code attribute to the given method. composer.addCodeAttribute(programClass, programMethod);This class is mostly convenient to compose code programmatically from scratch. To compose code based on existing code, where the instructions are already available, see
CodeAttributeComposer
.
If you're building many method bodies, it is more efficient to reuse
a single instance of this composer for all methods that you add.Modifier and Type | Class and Description |
---|---|
class |
CompactCodeAttributeComposer.Label
This class represents a label to which branch instructions and switch
instructions can jump.
|
Constructor and Description |
---|
CompactCodeAttributeComposer(ConstantPoolEditor constantPoolEditor,
boolean allowExternalBranchTargets,
boolean allowExternalExceptionOffsets,
boolean shrinkInstructions)
Creates a new CompactCodeAttributeComposer.
|
CompactCodeAttributeComposer(ConstantPoolEditor constantPoolEditor,
CodeAttributeComposer codeAttributeComposer)
Creates a new CompactCodeAttributeComposer.
|
CompactCodeAttributeComposer(ProgramClass targetClass)
Creates a new CompactCodeAttributeComposer that doesn't allow external
branch targets or exception offsets and that automatically shrinks
instructions.
|
CompactCodeAttributeComposer(ProgramClass targetClass,
boolean allowExternalBranchTargets,
boolean allowExternalExceptionOffsets,
boolean shrinkInstructions)
Creates a new CompactCodeAttributeComposer.
|
CompactCodeAttributeComposer(ProgramClass targetClass,
boolean allowExternalBranchTargets,
boolean allowExternalExceptionOffsets,
boolean shrinkInstructions,
ClassPool programClassPool,
ClassPool libraryClassPool)
Creates a new CompactCodeAttributeComposer.
|
CompactCodeAttributeComposer(ProgramClass targetClass,
ClassPool programClassPool,
ClassPool libraryClassPool)
Creates a new CompactCodeAttributeComposer that doesn't allow external
branch targets or exception handlers and that automatically shrinks
instructions.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
visitAnnotationDefaultAttribute, visitAnyAnnotationsAttribute, visitAnyParameterAnnotationsAttribute, visitAnyTypeAnnotationsAttribute, visitBootstrapMethodsAttribute, visitConstantValueAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitEnclosingMethodAttribute, visitExceptionsAttribute, visitInnerClassesAttribute, visitLineNumberTableAttribute, visitLocalVariableTableAttribute, visitLocalVariableTypeTableAttribute, visitMethodParametersAttribute, visitModuleAttribute, visitModuleMainClassAttribute, visitModulePackagesAttribute, visitNestHostAttribute, visitNestMembersAttribute, visitPermittedSubclassesAttribute, visitRecordAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleParameterAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleParameterAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSourceDebugExtensionAttribute, visitSourceDirAttribute, visitSourceFileAttribute, visitStackMapAttribute, visitStackMapTableAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitUnknownAttribute
public CompactCodeAttributeComposer(ProgramClass targetClass)
targetClass
- the class to be edited.public CompactCodeAttributeComposer(ProgramClass targetClass, ClassPool programClassPool, ClassPool libraryClassPool)
targetClass
- the class to be edited.programClassPool
- the program class pool from which new
constants can be initialized.libraryClassPool
- the library class pool from which new
constants can be initialized.public CompactCodeAttributeComposer(ProgramClass targetClass, boolean allowExternalBranchTargets, boolean allowExternalExceptionOffsets, boolean shrinkInstructions)
targetClass
- the class to be edited.allowExternalBranchTargets
- specifies whether branch targets
can lie outside the code fragment
of the branch instructions.allowExternalExceptionOffsets
- specifies whether exception
offsets can lie outside the code
fragment in which exceptions are
defined.shrinkInstructions
- specifies whether instructions
should automatically be shrunk
before being written.public CompactCodeAttributeComposer(ProgramClass targetClass, boolean allowExternalBranchTargets, boolean allowExternalExceptionOffsets, boolean shrinkInstructions, ClassPool programClassPool, ClassPool libraryClassPool)
targetClass
- the class to be edited.allowExternalBranchTargets
- specifies whether branch targets
can lie outside the code fragment
of the branch instructions.allowExternalExceptionOffsets
- specifies whether exception
offsets can lie outside the code
fragment in which exceptions are
defined.shrinkInstructions
- specifies whether instructions
should automatically be shrunk
before being written.programClassPool
- the program class pool from which new
constants can be initialized.libraryClassPool
- the library class pool from which new
constants can be initialized.public CompactCodeAttributeComposer(ConstantPoolEditor constantPoolEditor, boolean allowExternalBranchTargets, boolean allowExternalExceptionOffsets, boolean shrinkInstructions)
constantPoolEditor
- an editor for the constants in the
class.allowExternalBranchTargets
- specifies whether branch targets
can lie outside the code fragment
of the branch instructions.allowExternalExceptionOffsets
- specifies whether exception
offsets can lie outside the code
fragment in which exceptions are
defined.shrinkInstructions
- specifies whether instructions
should automatically be shrunk
before being written.public CompactCodeAttributeComposer(ConstantPoolEditor constantPoolEditor, CodeAttributeComposer codeAttributeComposer)
constantPoolEditor
- an editor for the constants in the class.codeAttributeComposer
- an composer for the instructions in the method.public ProgramClass getTargetClass()
public ConstantPoolEditor getConstantPoolEditor()
public int getCodeLength()
public CompactCodeAttributeComposer convertToTargetType(java.lang.String sourceType, java.lang.String targetType)
public CompactCodeAttributeComposer boxPrimitiveType(char sourceType)
sourceType
- type of the primitive on the stack.public CompactCodeAttributeComposer convertPrimitiveType(char source, char target)
source
- The source type.target
- The target type.public CompactCodeAttributeComposer unboxPrimitiveType(java.lang.String sourceType, java.lang.String targetType)
sourceType
- type of the primitive that should be unboxed.targetType
- resulting type.public CompactCodeAttributeComposer reset()
public CompactCodeAttributeComposer 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 CompactCodeAttributeComposer.Label createLabel()
public CompactCodeAttributeComposer label(CompactCodeAttributeComposer.Label label)
label
- the branch label.public CompactCodeAttributeComposer appendInstructions(Instruction[] instructions)
instructions
- the instructions to be appended.public CompactCodeAttributeComposer appendInstruction(Instruction instruction)
instruction
- the instruction to be appended.public CompactCodeAttributeComposer catchAll(CompactCodeAttributeComposer.Label startLabel, CompactCodeAttributeComposer.Label endLabel)
startLabel
- the start label of the try block.endLabel
- the end label of the try block.public CompactCodeAttributeComposer catchAll(CompactCodeAttributeComposer.Label startLabel, CompactCodeAttributeComposer.Label endLabel, CompactCodeAttributeComposer.Label handlerLabel)
startLabel
- the start label of the try block.endLabel
- the end label of the try block.handlerLabel
- the label of the exception handler.public CompactCodeAttributeComposer catch_(CompactCodeAttributeComposer.Label startLabel, CompactCodeAttributeComposer.Label endLabel, java.lang.String catchType, Clazz referencedClass)
startLabel
- the start label of the try block.endLabel
- the end label of the try block.catchType
- the exception type.referencedClass
- the exception class, if known.public CompactCodeAttributeComposer catch_(CompactCodeAttributeComposer.Label startLabel, CompactCodeAttributeComposer.Label endLabel, CompactCodeAttributeComposer.Label handlerLabel, java.lang.String catchType, Clazz referencedClass)
startLabel
- the start label of the try block.endLabel
- the end label of the try block.handlerLabel
- the label of the exception handler.catchType
- the exception type.referencedClass
- the exception class, if known.public CompactCodeAttributeComposer line(int lineNumber)
lineNumber
- the line number from the source code.public CompactCodeAttributeComposer endCodeFragment()
public CompactCodeAttributeComposer nop()
public CompactCodeAttributeComposer aconst_null()
public CompactCodeAttributeComposer iconst(int constant)
public CompactCodeAttributeComposer iconst_m1()
public CompactCodeAttributeComposer iconst_0()
public CompactCodeAttributeComposer iconst_1()
public CompactCodeAttributeComposer iconst_2()
public CompactCodeAttributeComposer iconst_3()
public CompactCodeAttributeComposer iconst_4()
public CompactCodeAttributeComposer iconst_5()
public CompactCodeAttributeComposer lconst(int constant)
public CompactCodeAttributeComposer lconst_0()
public CompactCodeAttributeComposer lconst_1()
public CompactCodeAttributeComposer fconst(int constant)
public CompactCodeAttributeComposer fconst_0()
public CompactCodeAttributeComposer fconst_1()
public CompactCodeAttributeComposer fconst_2()
public CompactCodeAttributeComposer dconst(int constant)
public CompactCodeAttributeComposer dconst_0()
public CompactCodeAttributeComposer dconst_1()
public CompactCodeAttributeComposer bipush(int constant)
public CompactCodeAttributeComposer sipush(int constant)
public CompactCodeAttributeComposer ldc(int value)
public CompactCodeAttributeComposer ldc(float value)
public CompactCodeAttributeComposer ldc(java.lang.String string)
public CompactCodeAttributeComposer ldc(java.lang.Object primitiveArray)
public CompactCodeAttributeComposer ldc(Clazz clazz, Member member)
public CompactCodeAttributeComposer ldc(java.lang.String string, Clazz referencedClass, Member referencedMember)
public CompactCodeAttributeComposer ldc(ResourceFile resourceFile)
public CompactCodeAttributeComposer ldc(java.lang.String string, ResourceFile referencedResourceFile)
public CompactCodeAttributeComposer ldc(Clazz clazz)
public CompactCodeAttributeComposer ldc(java.lang.String typeName, Clazz referencedClass)
public CompactCodeAttributeComposer ldc_(int constantIndex)
public CompactCodeAttributeComposer ldc_w(int value)
public CompactCodeAttributeComposer ldc_w(float value)
public CompactCodeAttributeComposer ldc_w(java.lang.String string)
public CompactCodeAttributeComposer ldc_w(java.lang.Object primitiveArray)
public CompactCodeAttributeComposer ldc_w(Clazz clazz, Member member)
public CompactCodeAttributeComposer ldc_w(java.lang.String string, Clazz referencedClass, Member referencedMember)
public CompactCodeAttributeComposer ldc_w(ResourceFile resourceFile)
public CompactCodeAttributeComposer ldc_w(java.lang.String string, ResourceFile referencedResourceFile)
public CompactCodeAttributeComposer ldc_w(Clazz clazz)
public CompactCodeAttributeComposer ldc_w(java.lang.String typeName, Clazz referencedClass)
public CompactCodeAttributeComposer ldc_w_(int constantIndex)
public CompactCodeAttributeComposer ldc2_w(long value)
public CompactCodeAttributeComposer ldc2_w(double value)
public CompactCodeAttributeComposer ldc2_w(int constantIndex)
public CompactCodeAttributeComposer iload(int variableIndex)
public CompactCodeAttributeComposer lload(int variableIndex)
public CompactCodeAttributeComposer fload(int variableIndex)
public CompactCodeAttributeComposer dload(int variableIndex)
public CompactCodeAttributeComposer aload(int variableIndex)
public CompactCodeAttributeComposer iload_0()
public CompactCodeAttributeComposer iload_1()
public CompactCodeAttributeComposer iload_2()
public CompactCodeAttributeComposer iload_3()
public CompactCodeAttributeComposer lload_0()
public CompactCodeAttributeComposer lload_1()
public CompactCodeAttributeComposer lload_2()
public CompactCodeAttributeComposer lload_3()
public CompactCodeAttributeComposer fload_0()
public CompactCodeAttributeComposer fload_1()
public CompactCodeAttributeComposer fload_2()
public CompactCodeAttributeComposer fload_3()
public CompactCodeAttributeComposer dload_0()
public CompactCodeAttributeComposer dload_1()
public CompactCodeAttributeComposer dload_2()
public CompactCodeAttributeComposer dload_3()
public CompactCodeAttributeComposer aload_0()
public CompactCodeAttributeComposer aload_1()
public CompactCodeAttributeComposer aload_2()
public CompactCodeAttributeComposer aload_3()
public CompactCodeAttributeComposer iaload()
public CompactCodeAttributeComposer laload()
public CompactCodeAttributeComposer faload()
public CompactCodeAttributeComposer daload()
public CompactCodeAttributeComposer aaload()
public CompactCodeAttributeComposer baload()
public CompactCodeAttributeComposer caload()
public CompactCodeAttributeComposer saload()
public CompactCodeAttributeComposer istore(int variableIndex)
public CompactCodeAttributeComposer lstore(int variableIndex)
public CompactCodeAttributeComposer fstore(int variableIndex)
public CompactCodeAttributeComposer dstore(int variableIndex)
public CompactCodeAttributeComposer astore(int variableIndex)
public CompactCodeAttributeComposer istore_0()
public CompactCodeAttributeComposer istore_1()
public CompactCodeAttributeComposer istore_2()
public CompactCodeAttributeComposer istore_3()
public CompactCodeAttributeComposer lstore_0()
public CompactCodeAttributeComposer lstore_1()
public CompactCodeAttributeComposer lstore_2()
public CompactCodeAttributeComposer lstore_3()
public CompactCodeAttributeComposer fstore_0()
public CompactCodeAttributeComposer fstore_1()
public CompactCodeAttributeComposer fstore_2()
public CompactCodeAttributeComposer fstore_3()
public CompactCodeAttributeComposer dstore_0()
public CompactCodeAttributeComposer dstore_1()
public CompactCodeAttributeComposer dstore_2()
public CompactCodeAttributeComposer dstore_3()
public CompactCodeAttributeComposer astore_0()
public CompactCodeAttributeComposer astore_1()
public CompactCodeAttributeComposer astore_2()
public CompactCodeAttributeComposer astore_3()
public CompactCodeAttributeComposer iastore()
public CompactCodeAttributeComposer lastore()
public CompactCodeAttributeComposer fastore()
public CompactCodeAttributeComposer dastore()
public CompactCodeAttributeComposer aastore()
public CompactCodeAttributeComposer bastore()
public CompactCodeAttributeComposer castore()
public CompactCodeAttributeComposer sastore()
public CompactCodeAttributeComposer pop()
public CompactCodeAttributeComposer pop2()
public CompactCodeAttributeComposer dup()
public CompactCodeAttributeComposer dup_x1()
public CompactCodeAttributeComposer dup_x2()
public CompactCodeAttributeComposer dup2()
public CompactCodeAttributeComposer dup2_x1()
public CompactCodeAttributeComposer dup2_x2()
public CompactCodeAttributeComposer swap()
public CompactCodeAttributeComposer iadd()
public CompactCodeAttributeComposer ladd()
public CompactCodeAttributeComposer fadd()
public CompactCodeAttributeComposer dadd()
public CompactCodeAttributeComposer isub()
public CompactCodeAttributeComposer lsub()
public CompactCodeAttributeComposer fsub()
public CompactCodeAttributeComposer dsub()
public CompactCodeAttributeComposer imul()
public CompactCodeAttributeComposer lmul()
public CompactCodeAttributeComposer fmul()
public CompactCodeAttributeComposer dmul()
public CompactCodeAttributeComposer idiv()
public CompactCodeAttributeComposer ldiv()
public CompactCodeAttributeComposer fdiv()
public CompactCodeAttributeComposer ddiv()
public CompactCodeAttributeComposer irem()
public CompactCodeAttributeComposer lrem()
public CompactCodeAttributeComposer frem()
public CompactCodeAttributeComposer drem()
public CompactCodeAttributeComposer ineg()
public CompactCodeAttributeComposer lneg()
public CompactCodeAttributeComposer fneg()
public CompactCodeAttributeComposer dneg()
public CompactCodeAttributeComposer ishl()
public CompactCodeAttributeComposer lshl()
public CompactCodeAttributeComposer ishr()
public CompactCodeAttributeComposer lshr()
public CompactCodeAttributeComposer iushr()
public CompactCodeAttributeComposer lushr()
public CompactCodeAttributeComposer iand()
public CompactCodeAttributeComposer land()
public CompactCodeAttributeComposer ior()
public CompactCodeAttributeComposer lor()
public CompactCodeAttributeComposer ixor()
public CompactCodeAttributeComposer lxor()
public CompactCodeAttributeComposer iinc(int variableIndex, int constant)
public CompactCodeAttributeComposer i2l()
public CompactCodeAttributeComposer i2f()
public CompactCodeAttributeComposer i2d()
public CompactCodeAttributeComposer l2i()
public CompactCodeAttributeComposer l2f()
public CompactCodeAttributeComposer l2d()
public CompactCodeAttributeComposer f2i()
public CompactCodeAttributeComposer f2l()
public CompactCodeAttributeComposer f2d()
public CompactCodeAttributeComposer d2i()
public CompactCodeAttributeComposer d2l()
public CompactCodeAttributeComposer d2f()
public CompactCodeAttributeComposer i2b()
public CompactCodeAttributeComposer i2c()
public CompactCodeAttributeComposer i2s()
public CompactCodeAttributeComposer lcmp()
public CompactCodeAttributeComposer fcmpl()
public CompactCodeAttributeComposer fcmpg()
public CompactCodeAttributeComposer dcmpl()
public CompactCodeAttributeComposer dcmpg()
public CompactCodeAttributeComposer ifeq(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ifne(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer iflt(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ifge(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ifgt(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ifle(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ificmpeq(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ificmpne(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ificmplt(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ificmpge(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ificmpgt(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ificmple(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ifacmpeq(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ifacmpne(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer goto_(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer jsr(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ret(int variableIndex)
public CompactCodeAttributeComposer tableswitch(CompactCodeAttributeComposer.Label defaultLabel, int lowCase, int highCase, CompactCodeAttributeComposer.Label[] jumpLabels)
public CompactCodeAttributeComposer lookupswitch(CompactCodeAttributeComposer.Label defaultLabel, int[] cases, CompactCodeAttributeComposer.Label[] jumpLabels)
public CompactCodeAttributeComposer ireturn()
public CompactCodeAttributeComposer lreturn()
public CompactCodeAttributeComposer freturn()
public CompactCodeAttributeComposer dreturn()
public CompactCodeAttributeComposer areturn()
public CompactCodeAttributeComposer return_()
public CompactCodeAttributeComposer getstatic(Clazz clazz, Field field)
public CompactCodeAttributeComposer getstatic(java.lang.String className, java.lang.String name, java.lang.String descriptor)
public CompactCodeAttributeComposer getstatic(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Field referencedField)
public CompactCodeAttributeComposer getstatic(int constantIndex)
public CompactCodeAttributeComposer putstatic(Clazz referencedClass, Field referencedField)
public CompactCodeAttributeComposer putstatic(java.lang.String className, java.lang.String name, java.lang.String descriptor)
public CompactCodeAttributeComposer putstatic(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Field referencedField)
public CompactCodeAttributeComposer putstatic(int constantIndex)
public CompactCodeAttributeComposer getfield(Clazz clazz, Field field)
public CompactCodeAttributeComposer getfield(java.lang.String className, java.lang.String name, java.lang.String descriptor)
public CompactCodeAttributeComposer getfield(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Field referencedField)
public CompactCodeAttributeComposer getfield(int constantIndex)
public CompactCodeAttributeComposer putfield(Clazz clazz, Field field)
public CompactCodeAttributeComposer putfield(java.lang.String className, java.lang.String name, java.lang.String descriptor)
public CompactCodeAttributeComposer putfield(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Field referencedField)
public CompactCodeAttributeComposer putfield(int constantIndex)
public CompactCodeAttributeComposer invokevirtual(Clazz clazz, Method method)
public CompactCodeAttributeComposer invokevirtual(java.lang.String className, java.lang.String name, java.lang.String descriptor)
public CompactCodeAttributeComposer invokevirtual(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Method referencedMethod)
public CompactCodeAttributeComposer invokevirtual(int constantIndex)
public CompactCodeAttributeComposer invokespecial(Clazz clazz, Method method)
public CompactCodeAttributeComposer invokespecial(java.lang.String className, java.lang.String name, java.lang.String descriptor)
public CompactCodeAttributeComposer invokespecial(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Method referencedMethod)
public CompactCodeAttributeComposer invokespecial(int constantIndex)
public CompactCodeAttributeComposer invokestatic(Clazz clazz, Method method)
public CompactCodeAttributeComposer invokestatic(java.lang.String className, java.lang.String name, java.lang.String descriptor)
public CompactCodeAttributeComposer invokestatic(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Method referencedMethod)
public CompactCodeAttributeComposer invokestatic_interface(Clazz clazz, Method method)
public CompactCodeAttributeComposer invokestatic_interface(java.lang.String className, java.lang.String name, java.lang.String descriptor)
public CompactCodeAttributeComposer invokestatic_interface(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Method referencedMethod)
public CompactCodeAttributeComposer invokestatic(int constantIndex)
public CompactCodeAttributeComposer invokeinterface(Clazz clazz, Method method)
public CompactCodeAttributeComposer invokeinterface(java.lang.String className, java.lang.String name, java.lang.String descriptor)
public CompactCodeAttributeComposer invokeinterface(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Method referencedMethod)
public CompactCodeAttributeComposer invokeinterface(int constantIndex, int constant)
public CompactCodeAttributeComposer invokedynamic(int bootStrapMethodIndex, java.lang.String name, java.lang.String descriptor, Clazz[] referencedClasses)
public CompactCodeAttributeComposer invokedynamic(int constantIndex)
public CompactCodeAttributeComposer new_(Clazz clazz)
public CompactCodeAttributeComposer new_(java.lang.String className)
public CompactCodeAttributeComposer new_(java.lang.String className, Clazz referencedClass)
public CompactCodeAttributeComposer new_(int constantIndex)
public CompactCodeAttributeComposer newarray(int constant)
public CompactCodeAttributeComposer anewarray(java.lang.String className, Clazz referencedClass)
public CompactCodeAttributeComposer anewarray(int constantIndex)
public CompactCodeAttributeComposer arraylength()
public CompactCodeAttributeComposer athrow()
public CompactCodeAttributeComposer checkcast(java.lang.String className)
public CompactCodeAttributeComposer checkcast(java.lang.String className, Clazz referencedClass)
public CompactCodeAttributeComposer checkcast(int constantIndex)
public CompactCodeAttributeComposer instanceof_(java.lang.String className, Clazz referencedClass)
public CompactCodeAttributeComposer instanceof_(int constantIndex)
public CompactCodeAttributeComposer monitorenter()
public CompactCodeAttributeComposer monitorexit()
public CompactCodeAttributeComposer wide()
public CompactCodeAttributeComposer multianewarray(java.lang.String className, Clazz referencedClass, int dimensions)
public CompactCodeAttributeComposer multianewarray(int constantIndex, int dimensions)
public CompactCodeAttributeComposer ifnull(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer ifnonnull(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer goto_w(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer jsr_w(CompactCodeAttributeComposer.Label branchLabel)
public CompactCodeAttributeComposer pushPrimitive(java.lang.Object primitive, char internalType)
primitive
- the primitive value to be pushed - should never be null.internalType
- the internal type of the primitive ('Z','B','I',...)public CompactCodeAttributeComposer pushInt(int value)
value
- the int value to be pushed.public CompactCodeAttributeComposer pushFloat(float value)
value
- the float value to be pushed.public CompactCodeAttributeComposer pushLong(long value)
value
- the long value to be pushed.public CompactCodeAttributeComposer pushDouble(double value)
value
- the double value to be pushed.public CompactCodeAttributeComposer pushNewArray(java.lang.String elementTypeOrClassName, int size)
elementTypeOrClassName
- the array element type (or class name in case of objects).size
- the size of the array to be created.public CompactCodeAttributeComposer load(int variableIndex, java.lang.String internalType)
variableIndex
- the index of the variable to be loaded.internalType
- the type of the variable to be loaded.public CompactCodeAttributeComposer load(int variableIndex, char internalType)
variableIndex
- the index of the variable to be loaded.internalType
- the primitive type of the variable to be loaded.public CompactCodeAttributeComposer store(int variableIndex, java.lang.String internalType)
variableIndex
- the index of the variable where to store the
value.internalType
- the type of the value to be stored.public CompactCodeAttributeComposer store(int variableIndex, char internalType)
variableIndex
- the index of the variable where to store the
value.internalType
- the primitive type of the value to be stored.public CompactCodeAttributeComposer storeToArray(java.lang.String elementType)
elementType
- the type of the value to be stored.public CompactCodeAttributeComposer return_(java.lang.String internalType)
internalType
- the return type.public CompactCodeAttributeComposer appendPrintIntegerInstructions(java.lang.String message)
public CompactCodeAttributeComposer appendPrintIntegerHexInstructions(java.lang.String message)
public CompactCodeAttributeComposer appendPrintLongInstructions(java.lang.String message)
public CompactCodeAttributeComposer appendPrintStringInstructions(java.lang.String message)
public CompactCodeAttributeComposer appendPrintObjectInstructions(java.lang.String message)
public CompactCodeAttributeComposer appendPrintStackTraceInstructions(java.lang.String message)
public CompactCodeAttributeComposer appendPrintInstructions(java.lang.String message)
public CompactCodeAttributeComposer appendPrintIntegerInstructions()
public CompactCodeAttributeComposer appendPrintIntegerHexInstructions()
public CompactCodeAttributeComposer appendPrintLongInstructions()
public CompactCodeAttributeComposer appendPrintStringInstructions()
public CompactCodeAttributeComposer appendPrintObjectInstructions()
public CompactCodeAttributeComposer appendPrintStackTraceInstructions()
public void addCodeAttribute(ProgramClass programClass, ProgramMethod programMethod)
public void visitAnyAttribute(Clazz clazz, Attribute attribute)
AttributeVisitor
visitAnyAttribute
in interface AttributeVisitor
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
visitCodeAttribute
in interface AttributeVisitor
public static void main(java.lang.String[] args)