Package proguard.classfile.editor
Class InstructionSequenceBuilder
java.lang.Object
proguard.classfile.editor.InstructionSequenceBuilder
This utility class allows to construct sequences of instructions and their constants.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new InstructionSequenceBuilder.InstructionSequenceBuilder(ClassPool programClassPool, ClassPool libraryClassPool) Creates a new InstructionSequenceBuilder that automatically initializes class references and class member references in new constants.InstructionSequenceBuilder(ConstantPoolEditor constantPoolEditor) Creates a new InstructionSequenceBuilder.InstructionSequenceBuilder(ProgramClass targetClass) Creates a new InstructionSequenceBuilder.InstructionSequenceBuilder(ProgramClass targetClass, ClassPool programClassPool, ClassPool libraryClassPool) Creates a new InstructionSequenceBuilder that automatically initializes class references and class member references in new constants. -
Method Summary
Modifier and TypeMethodDescription__()Short forinstructions().aaload()aastore()aload(int variableIndex) aload_0()aload_1()aload_2()aload_3()anewarray(int constantIndex) appendInstruction(Instruction instruction) Appends the given instruction.appendInstructions(Instruction[] instructions) Appends the given instructions.areturn()astore(int variableIndex) astore_0()astore_1()astore_2()astore_3()athrow()baload()bastore()bipush(int constant) boxPrimitiveType(char sourceType) Box the primitive value present on the stack.caload()castore()catch_(Instruction instruction) Short forappendInstruction(Instruction).checkcast(int constantIndex) Constant[]Returns the accumulated set of constants and resets the set in the builder.d2f()d2i()d2l()dadd()daload()dastore()dcmpg()dcmpl()dconst(int constant) dconst_0()dconst_1()ddiv()dload(int variableIndex) dload_0()dload_1()dload_2()dload_3()dmul()dneg()drem()dreturn()dstore(int variableIndex) dstore_0()dstore_1()dstore_2()dstore_3()dsub()dup()dup_x1()dup_x2()dup2()dup2_x1()dup2_x2()f2d()f2i()f2l()fadd()faload()fastore()fcmpg()fcmpl()fconst(int constant) fconst_0()fconst_1()fconst_2()fdiv()fload(int variableIndex) fload_0()fload_1()fload_2()fload_3()fmul()fneg()frem()freturn()fstore(int variableIndex) fstore_0()fstore_1()fstore_2()fstore_3()fsub()Returns the ConstantPoolEditor used by this builder to create constants.getfield(int constantIndex) getfield(String className, String name, String descriptor, Clazz referencedClass, Field referencedField) getstatic(int constantIndex) getstatic(String className, String name, String descriptor, Clazz referencedClass, Field referencedField) goto_(int branchOffset) goto_w(int branchOffset) i2b()i2c()i2d()i2f()i2l()i2s()iadd()iaload()iand()iastore()iconst(int constant) iconst_0()iconst_1()iconst_2()iconst_3()iconst_4()iconst_5()idiv()ifacmpeq(int branchOffset) ifacmpne(int branchOffset) ifeq(int branchOffset) ifge(int branchOffset) ifgt(int branchOffset) ificmpeq(int branchOffset) ificmpge(int branchOffset) ificmpgt(int branchOffset) ificmple(int branchOffset) ificmplt(int branchOffset) ificmpne(int branchOffset) ifle(int branchOffset) iflt(int branchOffset) ifne(int branchOffset) ifnonnull(int branchOffset) ifnull(int branchOffset) iinc(int variableIndex, int constant) iload(int variableIndex) iload_0()iload_1()iload_2()iload_3()imul()ineg()instanceof_(int constantIndex) instanceof_(String typeName, Clazz referencedClass) instanceof_(Clazz type) Returns the accumulated sequence of instructions and resets the sequence in the builder.invoke(byte opcode, String className, String name, String descriptor, Clazz referencedClass, Method referencedMethod) invokedynamic(int constantIndex) invokedynamic(int bootStrapMethodIndex, String name, String descriptor) invokedynamic(int bootStrapMethodIndex, String name, String descriptor, Clazz[] referencedClasses) invokeinterface(int constantIndex, int constant) invokeinterface(String className, String name, String descriptor) invokeinterface(String className, String name, String descriptor, Clazz referencedClass, Method referencedMethod) invokeinterface(Clazz clazz, Method method) invokespecial(int constantIndex) invokespecial(String className, String name, String descriptor) invokespecial(String className, String name, String descriptor, Clazz referencedClass, Method referencedMethod) invokespecial(Clazz clazz, Method method) invokespecial_interface(String className, String name, String descriptor) invokespecial_interface(String className, String name, String descriptor, Clazz referencedClass, Method referencedMethod) invokespecial_interface(Clazz clazz, Method method) invokestatic(int constantIndex) invokestatic(String className, String name, String descriptor) invokestatic(String className, String name, String descriptor, Clazz referencedClass, Method referencedMethod) invokestatic(Clazz clazz, Method method) invokestatic_interface(String className, String name, String descriptor) invokestatic_interface(String className, String name, String descriptor, Clazz referencedClass, Method referencedMethod) invokestatic_interface(Clazz clazz, Method method) invokevirtual(int constantIndex) invokevirtual(int classIndex, String name, String descriptor) invokevirtual(String className, String name, String descriptor) invokevirtual(String className, String name, String descriptor, Clazz referencedClass, Method referencedMethod) invokevirtual(Clazz clazz, Method method) ior()irem()ireturn()ishl()ishr()istore(int variableIndex) istore_0()istore_1()istore_2()istore_3()isub()iushr()ixor()jsr(int branchOffset) jsr_w(int branchOffset) l2d()l2f()l2i()label(Instruction instruction) Short forappendInstruction(Instruction).ladd()laload()land()lastore()lcmp()lconst(int constant) lconst_0()lconst_1()ldc(float value) Appends an ldc instruction that loads a float constant with the given value.ldc(float value, ConstantVisitor visitor) Appends an ldc instruction that loads a float constant with the given value.ldc(int value) Appends an ldc instruction that loads an integer constant with the given value.ldc(int value, ConstantVisitor visitor) Appends an ldc instruction that loads an integer constant with the given value.Appends an ldc instruction that loads an (internal) primitive array constant with the given value.ldc(Object primitiveArray, ConstantVisitor visitor) Appends an ldc instruction that loads an (internal) primitive array constant with the given value.Appends an ldc instruction that loads a string constant with the given value.Appends an ldc instruction that loads a class constant for the given type name, that references the given class.ldc(String typeName, Clazz referencedClass, ConstantVisitor visitor) Appends an ldc instruction that loads a class constant for the given type name, that references the given class.Appends an ldc instruction that loads a string constant with the given value, that references the given class member.ldc(String string, Clazz referencedClass, Member referencedMember, ConstantVisitor visitor) Appends an ldc instruction that loads a string constant with the given value, that references the given class member.ldc(String string, ConstantVisitor visitor) Appends an ldc instruction that loads a string constant with the given value.ldc(String string, ResourceFile referencedResourceFile) Appends an ldc instruction that loads a string constant with the given value, that references the given resource file.ldc(String string, ResourceFile referencedResourceFile, ConstantVisitor visitor) Appends an ldc instruction that loads a string constant with the given value, that references the given resource file.Appends an ldc instruction that loads a class constant for the given class.ldc(Clazz clazz, ConstantVisitor visitor) Appends an ldc instruction that loads a class constant for the given class.Appends an ldc instruction that loads a string constant with the given class member name.ldc(Clazz clazz, Member member, ConstantVisitor visitor) Appends an ldc instruction that loads a string constant with the given class member name.ldc(ResourceFile resourceFile) Appends an ldc instruction that loads a string constant with the given resource file name.ldc(ResourceFile resourceFile, ConstantVisitor visitor) Appends an ldc instruction that loads a string constant with the given resource file name.ldc_(int constantIndex) Appends an ldc instruction that loads the constant at the given index.ldc_(int constantIndex, ConstantVisitor visitor) Appends an ldc instruction that loads the constant at the given index.ldc_w(float value) Appends an ldc_w instruction that loads a float constant with the given value.ldc_w(float value, ConstantVisitor visitor) Appends an ldc_w instruction that loads a float constant with the given value.ldc_w(int value) Appends an ldc_w instruction that loads an integer constant with the given value.ldc_w(int value, ConstantVisitor visitor) Appends an ldc_w instruction that loads an integer constant with the given value.Appends an ldc_w instruction that loads an (internal) primitive array constant with the given value.ldc_w(Object primitiveArray, ConstantVisitor visitor) Appends an ldc_w instruction that loads an (internal) primitive array constant with the given value.Appends an ldc_w instruction that loads a string constant with the given value.Appends an ldc_w instruction that loads a class constant for the given type name, that references the given class.ldc_w(String typeName, Clazz referencedClass, ConstantVisitor visitor) Appends an ldc_w instruction that loads a class constant for the given type name, that references the given class.Appends an ldc_w instruction that loads a string constant with the given value, that references the given class member.ldc_w(String string, Clazz referencedClass, Member referencedMember, ConstantVisitor visitor) Appends an ldc_w instruction that loads a string constant with the given value, that references the given class member.ldc_w(String string, ConstantVisitor visitor) Appends an ldc_w instruction that loads a string constant with the given value.ldc_w(String string, ResourceFile referencedResourceFile) Appends an ldc_w instruction that loads a string constant with the given value, that references the given resource file.ldc_w(String string, ResourceFile referencedResourceFile, ConstantVisitor visitor) Appends an ldc_w instruction that loads a string constant with the given value, that references the given resource file.Appends an ldc_w instruction that loads a class constant for the given class.ldc_w(Clazz clazz, ConstantVisitor visitor) Appends an ldc_w instruction that loads a class constant for the given class.Appends an ldc_w instruction that loads a string constant with the given class member name.ldc_w(Clazz clazz, Member member, ConstantVisitor visitor) Appends an ldc_w instruction that loads a string constant with the given class member name.ldc_w(ResourceFile resourceFile) Appends an ldc_w instruction that loads a string constant with the given resource file name.ldc_w(ResourceFile resourceFile, ConstantVisitor visitor) Appends an ldc_w instruction that loads a string constant with the given resource file name.ldc_w_(int constantIndex) Appends an ldc_w instruction that loads the constant at the given index.ldc_w_(int constantIndex, ConstantVisitor visitor) Appends an ldc_w instruction that loads the constant at the given index.ldc2_w(double value) Appends an ldc2_w instruction that loads a double constant with the given value.ldc2_w(double value, ConstantVisitor visitor) Appends an ldc2_w instruction that loads a double constant with the given value.ldc2_w(int constantIndex) Appends an ldc2_w instruction that loads the Category 2 constant at the given index.ldc2_w(int constantIndex, ConstantVisitor visitor) Appends an ldc2_w instruction that loads the Category 2 constant at the given index.ldc2_w(long value) Appends an ldc2_w instruction that loads a long constant with the given value.ldc2_w(long value, ConstantVisitor visitor) Appends an ldc2_w instruction that loads a long constant with the given value.ldiv()line(Instruction instruction) Short forappendInstruction(Instruction).lload(int variableIndex) lload_0()lload_1()lload_2()lload_3()lmul()lneg()load(int variableIndex, char type) Loads the given variable of primitive type onto the stack.Loads the given variable onto the stack.loadFromArray(String elementType) Loads an element from an array.lookupswitch(int defaultOffset, int[] cases, int[] jumpOffsets) lor()lrem()lreturn()lshl()lshr()lstore(int variableIndex) lstore_0()lstore_1()lstore_2()lstore_3()lsub()lushr()lxor()static voidSmall sample application that illustrates the use of this class.multianewarray(int constantIndex) multianewarray(String typeName) multianewarray(String typeName, Clazz referencedClass) multianewarray(Clazz type) new_(int constantIndex) newarray(int constant) nop()pop()pop2()pushBoxedPrimitive(Object value, String type) Push a primitive on the stack followed by a call to it's boxed valueOf method.pushDefault(String type) Pushes a default value onto the stack.pushDouble(double value) Pushes the given primitive double on the stack in the most efficient way (as a dconst or ldc instruction).pushFloat(float value) Pushes the given primitive float on the stack in the most efficient way (as an fconst or ldc instruction).pushInt(int value) Pushes the given primitive int on the stack in the most efficient way (as an iconst, bipush, sipush, or ldc instruction).pushLong(long value) Pushes the given primitive long on the stack in the most efficient way (as an lconst or ldc instruction).pushNewArray(String type, int size) Pushes a new array on the stack.pushPrimitive(Object value, char type) Pushes the given primitive value on the stack.pushPrimitiveOrString(Object value, String type) Pushes the given string or primitive on the stack.pushPrimitiveOrString(Object value, String type, boolean allowBoxing) Pushes the given string or primitive on the stack.pushPrimitiveOrStringArray(String type, Object[] values) Pushes a new array with given values onto the stack.putfield(int constantIndex) putfield(String className, String name, String descriptor, Clazz referencedClass, Field referencedField) putstatic(int constantIndex) putstatic(String className, String name, String descriptor, Clazz referencedClass, Field referencedField) ret(int variableIndex) return_()saload()sastore()sipush(int constant) intsize()Returns the number of instructions accumulated by this InstructionSequenceBuilder.store(int variableIndex, char type) Stores the primitve value on top of the stack in the variable with given index.Stores the value on top of the stack in the variable with given index.storeToArray(String elementType) Stores an element to an array.swap()tableswitch(int defaultOffset, int lowCase, int highCase, int[] jumpOffsets) unboxPrimitiveType(String sourceType, String targetType) Unbox the object on the stack to a primitive value.wide()
-
Constructor Details
-
InstructionSequenceBuilder
public InstructionSequenceBuilder()Creates a new InstructionSequenceBuilder. -
InstructionSequenceBuilder
Creates a new InstructionSequenceBuilder that automatically initializes class references and class member references in new constants.- Parameters:
programClassPool- The program class pool from which new constants can be initialized.libraryClassPool- The library class pool from which new constants can be initialized.
-
InstructionSequenceBuilder
Creates a new InstructionSequenceBuilder.- Parameters:
targetClass- The target class for the instruction constants.
-
InstructionSequenceBuilder
public InstructionSequenceBuilder(ProgramClass targetClass, ClassPool programClassPool, ClassPool libraryClassPool) Creates a new InstructionSequenceBuilder that automatically initializes class references and class member references in new constants.- Parameters:
targetClass- The target class for the instruction constants.programClassPool- The program class pool from which new constants can be initialized.libraryClassPool- The library class pool from which new constants can be initialized.
-
InstructionSequenceBuilder
Creates a new InstructionSequenceBuilder.- Parameters:
constantPoolEditor- The editor to use for creating any constants for the instructions.
-
-
Method Details
-
getConstantPoolEditor
Returns the ConstantPoolEditor used by this builder to create constants.- Returns:
- The ConstantPoolEditor used by this builder to create constants.
-
label
Short forappendInstruction(Instruction).- See Also:
-
catch_
Short forappendInstruction(Instruction). -
line
Short forappendInstruction(Instruction). -
appendInstruction
Appends the given instruction.- Parameters:
instruction- The instruction to be appended.- Returns:
- The builder itself.
-
appendInstructions
Appends the given instructions.- Parameters:
instructions- The instructions to be appended.- Returns:
- The builder itself.
-
__
Short forinstructions(). -
instructions
Returns the accumulated sequence of instructions and resets the sequence in the builder. -
constants
Returns the accumulated set of constants and resets the set in the builder. -
size
public int size()Returns the number of instructions accumulated by this InstructionSequenceBuilder. -
nop
-
aconst_null
-
iconst
-
iconst_m1
-
iconst_0
-
iconst_1
-
iconst_2
-
iconst_3
-
iconst_4
-
iconst_5
-
lconst
-
lconst_0
-
lconst_1
-
fconst
-
fconst_0
-
fconst_1
-
fconst_2
-
dconst
-
dconst_0
-
dconst_1
-
bipush
-
sipush
-
ldc
Appends an ldc instruction that loads an integer constant with the given value. -
ldc
Appends an ldc instruction that loads an integer constant with the given value. Also visits the constant with the given visitor. -
ldc
Appends an ldc instruction that loads a float constant with the given value. -
ldc
Appends an ldc instruction that loads a float constant with the given value. Also visits the constant with the given visitor. -
ldc
Appends an ldc instruction that loads a string constant with the given value. -
ldc
Appends an ldc instruction that loads a string constant with the given value. Also visits the constant with the given visitor. -
ldc
Appends an ldc instruction that loads an (internal) primitive array constant with the given value. -
ldc
Appends an ldc instruction that loads an (internal) primitive array constant with the given value. Also visits the constant with the given visitor. -
ldc
Appends an ldc instruction that loads a string constant with the given class member name. -
ldc
Appends an ldc instruction that loads a string constant with the given class member name. Also visits the constant with the given visitor. -
ldc
public InstructionSequenceBuilder ldc(String string, Clazz referencedClass, Member referencedMember) Appends an ldc instruction that loads a string constant with the given value, that references the given class member. -
ldc
public InstructionSequenceBuilder ldc(String string, Clazz referencedClass, Member referencedMember, ConstantVisitor visitor) Appends an ldc instruction that loads a string constant with the given value, that references the given class member. Also visits the constant with the given visitor. -
ldc
Appends an ldc instruction that loads a string constant with the given resource file name. -
ldc
Appends an ldc instruction that loads a string constant with the given resource file name. Also visits the constant with the given visitor. -
ldc
Appends an ldc instruction that loads a string constant with the given value, that references the given resource file. -
ldc
public InstructionSequenceBuilder ldc(String string, ResourceFile referencedResourceFile, ConstantVisitor visitor) Appends an ldc instruction that loads a string constant with the given value, that references the given resource file. Also visits the constant with the given visitor. -
ldc
Appends an ldc instruction that loads a class constant for the given class. -
ldc
Appends an ldc instruction that loads a class constant for the given class. Also visits the constant with the given visitor. -
ldc
Appends an ldc instruction that loads a class constant for the given type name, that references the given class. -
ldc
public InstructionSequenceBuilder ldc(String typeName, Clazz referencedClass, ConstantVisitor visitor) Appends an ldc instruction that loads a class constant for the given type name, that references the given class. Also visits the constant with the given visitor. -
ldc_
Appends an ldc instruction that loads the constant at the given index. -
ldc_
Appends an ldc instruction that loads the constant at the given index. Also visits the constant with the given visitor. -
ldc_w
Appends an ldc_w instruction that loads an integer constant with the given value. -
ldc_w
Appends an ldc_w instruction that loads an integer constant with the given value. Also visits the constant with the given visitor. -
ldc_w
Appends an ldc_w instruction that loads a float constant with the given value. -
ldc_w
Appends an ldc_w instruction that loads a float constant with the given value. Also visits the constant with the given visitor. -
ldc_w
Appends an ldc_w instruction that loads a string constant with the given value. -
ldc_w
Appends an ldc_w instruction that loads a string constant with the given value. Also visits the constant with the given visitor. -
ldc_w
Appends an ldc_w instruction that loads an (internal) primitive array constant with the given value. -
ldc_w
Appends an ldc_w instruction that loads an (internal) primitive array constant with the given value. Also visits the constant with the given visitor. -
ldc_w
Appends an ldc_w instruction that loads a string constant with the given class member name. -
ldc_w
Appends an ldc_w instruction that loads a string constant with the given class member name. Also visits the constant with the given visitor. -
ldc_w
public InstructionSequenceBuilder ldc_w(String string, Clazz referencedClass, Member referencedMember) Appends an ldc_w instruction that loads a string constant with the given value, that references the given class member. -
ldc_w
public InstructionSequenceBuilder ldc_w(String string, Clazz referencedClass, Member referencedMember, ConstantVisitor visitor) Appends an ldc_w instruction that loads a string constant with the given value, that references the given class member. Also visits the constant with the given visitor. -
ldc_w
Appends an ldc_w instruction that loads a string constant with the given resource file name. -
ldc_w
Appends an ldc_w instruction that loads a string constant with the given resource file name. Also visits the constant with the given visitor. -
ldc_w
Appends an ldc_w instruction that loads a string constant with the given value, that references the given resource file. -
ldc_w
public InstructionSequenceBuilder ldc_w(String string, ResourceFile referencedResourceFile, ConstantVisitor visitor) Appends an ldc_w instruction that loads a string constant with the given value, that references the given resource file. Also visits the constant with the given visitor. -
ldc_w
Appends an ldc_w instruction that loads a class constant for the given class. -
ldc_w
Appends an ldc_w instruction that loads a class constant for the given class. Also visits the constant with the given visitor. -
ldc_w
Appends an ldc_w instruction that loads a class constant for the given type name, that references the given class. -
ldc_w
public InstructionSequenceBuilder ldc_w(String typeName, Clazz referencedClass, ConstantVisitor visitor) Appends an ldc_w instruction that loads a class constant for the given type name, that references the given class. Also visits the constant with the given visitor. -
ldc_w_
Appends an ldc_w instruction that loads the constant at the given index. -
ldc_w_
Appends an ldc_w instruction that loads the constant at the given index. Also visits the constant with the given visitor. -
ldc2_w
Appends an ldc2_w instruction that loads a long constant with the given value. -
ldc2_w
Appends an ldc2_w instruction that loads a long constant with the given value. Also visits the constant with the given index. -
ldc2_w
Appends an ldc2_w instruction that loads a double constant with the given value. -
ldc2_w
Appends an ldc2_w instruction that loads a double constant with the given value. Also visits the constant with the given index. -
ldc2_w
Appends an ldc2_w instruction that loads the Category 2 constant at the given index. -
ldc2_w
Appends an ldc2_w instruction that loads the Category 2 constant at the given index. Also visits the constant with the given visitor. -
iload
-
lload
-
fload
-
dload
-
aload
-
iload_0
-
iload_1
-
iload_2
-
iload_3
-
lload_0
-
lload_1
-
lload_2
-
lload_3
-
fload_0
-
fload_1
-
fload_2
-
fload_3
-
dload_0
-
dload_1
-
dload_2
-
dload_3
-
aload_0
-
aload_1
-
aload_2
-
aload_3
-
iaload
-
laload
-
faload
-
daload
-
aaload
-
baload
-
caload
-
saload
-
istore
-
lstore
-
fstore
-
dstore
-
astore
-
istore_0
-
istore_1
-
istore_2
-
istore_3
-
lstore_0
-
lstore_1
-
lstore_2
-
lstore_3
-
fstore_0
-
fstore_1
-
fstore_2
-
fstore_3
-
dstore_0
-
dstore_1
-
dstore_2
-
dstore_3
-
astore_0
-
astore_1
-
astore_2
-
astore_3
-
iastore
-
lastore
-
fastore
-
dastore
-
aastore
-
bastore
-
castore
-
sastore
-
pop
-
pop2
-
dup
-
dup_x1
-
dup_x2
-
dup2
-
dup2_x1
-
dup2_x2
-
swap
-
iadd
-
ladd
-
fadd
-
dadd
-
isub
-
lsub
-
fsub
-
dsub
-
imul
-
lmul
-
fmul
-
dmul
-
idiv
-
ldiv
-
fdiv
-
ddiv
-
irem
-
lrem
-
frem
-
drem
-
ineg
-
lneg
-
fneg
-
dneg
-
ishl
-
lshl
-
ishr
-
lshr
-
iushr
-
lushr
-
iand
-
land
-
ior
-
lor
-
ixor
-
lxor
-
iinc
-
i2l
-
i2f
-
i2d
-
l2i
-
l2f
-
l2d
-
f2i
-
f2l
-
f2d
-
d2i
-
d2l
-
d2f
-
i2b
-
i2c
-
i2s
-
lcmp
-
fcmpl
-
fcmpg
-
dcmpl
-
dcmpg
-
ifeq
-
ifne
-
iflt
-
ifge
-
ifgt
-
ifle
-
ificmpeq
-
ificmpne
-
ificmplt
-
ificmpge
-
ificmpgt
-
ificmple
-
ifacmpeq
-
ifacmpne
-
goto_
-
jsr
-
ret
-
tableswitch
public InstructionSequenceBuilder tableswitch(int defaultOffset, int lowCase, int highCase, int[] jumpOffsets) -
lookupswitch
-
return_
-
ireturn
-
lreturn
-
freturn
-
dreturn
-
areturn
-
return_
-
getstatic
-
getstatic
-
getstatic
-
getstatic
-
putstatic
-
putstatic
-
putstatic
-
putstatic
-
getfield
-
getfield
-
getfield
-
getfield
-
putfield
-
putfield
-
putfield
-
putfield
-
invoke
-
invoke
public InstructionSequenceBuilder invoke(byte opcode, Clazz referencedClass, Method referencedMethod) -
invoke
-
invokevirtual
-
invokevirtual
-
invokevirtual
-
invokevirtual
-
invokevirtual
-
invokespecial
-
invokespecial
-
invokespecial
-
invokespecial_interface
-
invokespecial_interface
public InstructionSequenceBuilder invokespecial_interface(String className, String name, String descriptor) -
invokespecial_interface
-
invokespecial
-
invokestatic
-
invokestatic
-
invokestatic
-
invokestatic_interface
-
invokestatic_interface
public InstructionSequenceBuilder invokestatic_interface(String className, String name, String descriptor) -
invokestatic_interface
-
invokestatic
-
invokeinterface
-
invokeinterface
-
invokeinterface
-
invokeinterface
-
invokedynamic
public InstructionSequenceBuilder invokedynamic(int bootStrapMethodIndex, String name, String descriptor) -
invokedynamic
public InstructionSequenceBuilder invokedynamic(int bootStrapMethodIndex, String name, String descriptor, Clazz[] referencedClasses) -
invokedynamic
-
new_
-
new_
-
new_
-
new_
-
newarray
-
anewarray
-
anewarray
-
anewarray
-
arraylength
-
athrow
-
checkcast
-
checkcast
-
checkcast
-
checkcast
-
instanceof_
-
instanceof_
-
instanceof_
-
monitorenter
-
monitorexit
-
wide
-
multianewarray
-
multianewarray
-
multianewarray
-
multianewarray
-
ifnull
-
ifnonnull
-
goto_w
-
jsr_w
-
pushPrimitive
Pushes the given primitive value on the stack.Operand stack: ... -> ..., value.
- Parameters:
value- The primitive value to be pushed - should never be null.type- The internal type of the primitive ('Z','B','I',...).
-
boxPrimitiveType
Box the primitive value present on the stack.Operand stack: ..., primitive -> ..., boxed_primitive.
- Parameters:
sourceType- Type of the primitive on the stack.- Returns:
- This.
-
unboxPrimitiveType
Unbox the object on the stack to a primitive value.Operand stack: ..., boxed_primitive -> ..., primitive.
- Parameters:
sourceType- Type of the primitive that should be unboxed.targetType- Resulting type.
-
pushPrimitiveOrString
Pushes the given string or primitive on the stack.- Parameters:
value- The primitive value to be pushed - should never be null.type- The internal type of the primitive ('Z','B','I',...).- Throws:
IllegalArgumentException- if the type is neither primitive orLjava/lang/String;.
-
pushPrimitiveOrString
public InstructionSequenceBuilder pushPrimitiveOrString(Object value, String type, boolean allowBoxing) Pushes the given string or primitive on the stack.- Parameters:
value- The primitive value to be pushed - should never be null.type- The internal type of the primitive ('Z','B','I',...).allowBoxing- If the type is a primitive wrapper class, set allowBoxing = true, to push a boxed primitive.- Throws:
IllegalArgumentException- if the type is neither primitive orLjava/lang/String;.
-
pushBoxedPrimitive
Push a primitive on the stack followed by a call to it's boxed valueOf method.- Parameters:
value- The value.type- The type, e.g.Ljava/lang/Integer;.
-
pushInt
Pushes the given primitive int on the stack in the most efficient way (as an iconst, bipush, sipush, or ldc instruction).- Parameters:
value- The int value to be pushed.
-
pushFloat
Pushes the given primitive float on the stack in the most efficient way (as an fconst or ldc instruction).- Parameters:
value- The float value to be pushed.
-
pushLong
Pushes the given primitive long on the stack in the most efficient way (as an lconst or ldc instruction).- Parameters:
value- The long to be pushed.
-
pushDouble
Pushes the given primitive double on the stack in the most efficient way (as a dconst or ldc instruction).- Parameters:
value- The double value to be pushed.
-
pushNewArray
Pushes a new array on the stack.Operand stack: ... -> ..., array.
- Parameters:
type- The array element type (or class name in case of objects).size- The size of the array to be created.
-
pushPrimitiveOrStringArray
Pushes a new array with given values onto the stack.For primitives you can specify, for example, either I or Ljava/lang/Integer; to create an object array or a primitive array.
Operand stack: ... -> ..., array.
- Parameters:
type- The array element type (or class name in case of objects).values- The array values.
-
pushDefault
Pushes a default value onto the stack.Either 0 for primitives or null for objects.
- Parameters:
type- The type.
-
load
Loads the given variable onto the stack.Operand stack: ... -> ..., value.
- Parameters:
variableIndex- The index of the variable to be loaded.type- The type of the variable to be loaded.
-
load
Loads the given variable of primitive type onto the stack.Operand stack: ... -> ..., value.
- Parameters:
variableIndex- The index of the variable to be loaded.type- The type of the variable to be loaded.
-
store
Stores the value on top of the stack in the variable with given index.Operand stsack: ..., value -> ...
- Parameters:
variableIndex- The index of the variable where to store the value.type- The type of the value to be stored.
-
store
Stores the primitve value on top of the stack in the variable with given index.Operand stack: ..., value -> ...
- Parameters:
variableIndex- The index of the variable where to store the value.type- The type of the value to be stored.
-
storeToArray
Stores an element to an array.Operand stack: ..., array, index, value -> ...
- Parameters:
elementType- The type of the value to be stored.
-
loadFromArray
Loads an element from an array.Operand stack: ..., array, index -> ..., value.
- Parameters:
elementType- The type of the value to be loaded.
-
main
Small sample application that illustrates the use of this class.
-