Package org.objectweb.asm.commons
Class InstructionAdapter
- java.lang.Object
-
- org.objectweb.asm.MethodVisitor
-
- org.objectweb.asm.commons.InstructionAdapter
-
public class InstructionAdapter extends org.objectweb.asm.MethodVisitor
AMethodVisitor
providing a more detailed API to generate and transform instructions.
-
-
Field Summary
Fields Modifier and Type Field Description static org.objectweb.asm.Type
OBJECT_TYPE
The type of the java.lang.Object class.
-
Constructor Summary
Constructors Modifier Constructor Description protected
InstructionAdapter(int api, org.objectweb.asm.MethodVisitor methodVisitor)
Constructs a newInstructionAdapter
.InstructionAdapter(org.objectweb.asm.MethodVisitor methodVisitor)
Constructs a newInstructionAdapter
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
aconst(java.lang.Object value)
Generates the instruction to push the given value on the stack.void
add(org.objectweb.asm.Type type)
void
aload(org.objectweb.asm.Type type)
void
and(org.objectweb.asm.Type type)
void
anew(org.objectweb.asm.Type type)
void
areturn(org.objectweb.asm.Type type)
void
arraylength()
void
astore(org.objectweb.asm.Type type)
void
athrow()
void
cast(org.objectweb.asm.Type from, org.objectweb.asm.Type to)
Generates the instruction to cast from the first given type to the other.void
cconst(org.objectweb.asm.ConstantDynamic constantDynamic)
Generates the instruction to push the given constant dynamic on the stack.void
checkcast(org.objectweb.asm.Type type)
void
cmpg(org.objectweb.asm.Type type)
void
cmpl(org.objectweb.asm.Type type)
void
dconst(double doubleValue)
Generates the instruction to push the given value on the stack.void
div(org.objectweb.asm.Type type)
void
dup()
void
dup2()
void
dup2X1()
void
dup2X2()
void
dupX1()
void
dupX2()
void
fconst(float floatValue)
Generates the instruction to push the given value on the stack.void
getfield(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
void
getstatic(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
void
goTo(org.objectweb.asm.Label label)
void
hconst(org.objectweb.asm.Handle handle)
Generates the instruction to push the given handle on the stack.void
iconst(int intValue)
Generates the instruction to push the given value on the stack.void
ifacmpeq(org.objectweb.asm.Label label)
void
ifacmpne(org.objectweb.asm.Label label)
void
ifeq(org.objectweb.asm.Label label)
void
ifge(org.objectweb.asm.Label label)
void
ifgt(org.objectweb.asm.Label label)
void
ificmpeq(org.objectweb.asm.Label label)
void
ificmpge(org.objectweb.asm.Label label)
void
ificmpgt(org.objectweb.asm.Label label)
void
ificmple(org.objectweb.asm.Label label)
void
ificmplt(org.objectweb.asm.Label label)
void
ificmpne(org.objectweb.asm.Label label)
void
ifle(org.objectweb.asm.Label label)
void
iflt(org.objectweb.asm.Label label)
void
ifne(org.objectweb.asm.Label label)
void
ifnonnull(org.objectweb.asm.Label label)
void
ifnull(org.objectweb.asm.Label label)
void
iinc(int var, int increment)
void
instanceOf(org.objectweb.asm.Type type)
void
invokedynamic(java.lang.String name, java.lang.String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, java.lang.Object[] bootstrapMethodArguments)
Generates the instruction to call the given dynamic method.void
invokeinterface(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
Generates the instruction to call the given interface method.void
invokespecial(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
Deprecated.useinvokespecial(String, String, String, boolean)
instead.void
invokespecial(java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
Generates the instruction to call the given special method.void
invokestatic(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
Deprecated.useinvokestatic(String, String, String, boolean)
instead.void
invokestatic(java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
Generates the instruction to call the given static method.void
invokevirtual(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
Deprecated.useinvokevirtual(String, String, String, boolean)
instead.void
invokevirtual(java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
Generates the instruction to call the given virtual method.void
jsr(org.objectweb.asm.Label label)
void
lcmp()
void
lconst(long longValue)
Generates the instruction to push the given value on the stack.void
load(int var, org.objectweb.asm.Type type)
void
lookupswitch(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
void
mark(org.objectweb.asm.Label label)
void
monitorenter()
void
monitorexit()
void
mul(org.objectweb.asm.Type type)
void
multianewarray(java.lang.String descriptor, int numDimensions)
void
neg(org.objectweb.asm.Type type)
void
newarray(org.objectweb.asm.Type type)
Generates the instruction to create and push on the stack an array of the given type.void
nop()
Generates a nop instruction.void
or(org.objectweb.asm.Type type)
void
pop()
void
pop2()
void
putfield(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
void
putstatic(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
void
rem(org.objectweb.asm.Type type)
void
ret(int var)
void
shl(org.objectweb.asm.Type type)
void
shr(org.objectweb.asm.Type type)
void
store(int var, org.objectweb.asm.Type type)
void
sub(org.objectweb.asm.Type type)
void
swap()
void
tableswitch(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)
void
tconst(org.objectweb.asm.Type type)
Generates the instruction to push the given type on the stack.void
ushr(org.objectweb.asm.Type type)
void
visitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor)
void
visitIincInsn(int var, int increment)
void
visitInsn(int opcode)
void
visitIntInsn(int opcode, int operand)
void
visitInvokeDynamicInsn(java.lang.String name, java.lang.String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)
void
visitJumpInsn(int opcode, org.objectweb.asm.Label label)
void
visitLabel(org.objectweb.asm.Label label)
void
visitLdcInsn(java.lang.Object value)
void
visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
void
visitMethodInsn(int opcodeAndSource, java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
void
visitMultiANewArrayInsn(java.lang.String descriptor, int numDimensions)
void
visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)
void
visitTypeInsn(int opcode, java.lang.String type)
void
visitVarInsn(int opcode, int var)
void
xor(org.objectweb.asm.Type type)
-
Methods inherited from class org.objectweb.asm.MethodVisitor
visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFrame, visitInsnAnnotation, visitLineNumber, visitLocalVariable, visitLocalVariableAnnotation, visitMaxs, visitMethodInsn, visitParameter, visitParameterAnnotation, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation
-
-
-
-
Constructor Detail
-
InstructionAdapter
public InstructionAdapter(org.objectweb.asm.MethodVisitor methodVisitor)
Constructs a newInstructionAdapter
. Subclasses must not use this constructor. Instead, they must use theInstructionAdapter(int, MethodVisitor)
version.- Parameters:
methodVisitor
- the method visitor to which this adapter delegates calls.- Throws:
java.lang.IllegalStateException
- If a subclass calls this constructor.
-
InstructionAdapter
protected InstructionAdapter(int api, org.objectweb.asm.MethodVisitor methodVisitor)
Constructs a newInstructionAdapter
.- Parameters:
api
- the ASM API version implemented by this visitor. Must be one ofOpcodes.ASM4
,Opcodes.ASM5
,Opcodes.ASM6
,Opcodes.ASM7
,Opcodes.ASM8
orOpcodes.ASM9
.methodVisitor
- the method visitor to which this adapter delegates calls.
-
-
Method Detail
-
visitInsn
public void visitInsn(int opcode)
- Overrides:
visitInsn
in classorg.objectweb.asm.MethodVisitor
-
visitIntInsn
public void visitIntInsn(int opcode, int operand)
- Overrides:
visitIntInsn
in classorg.objectweb.asm.MethodVisitor
-
visitVarInsn
public void visitVarInsn(int opcode, int var)
- Overrides:
visitVarInsn
in classorg.objectweb.asm.MethodVisitor
-
visitTypeInsn
public void visitTypeInsn(int opcode, java.lang.String type)
- Overrides:
visitTypeInsn
in classorg.objectweb.asm.MethodVisitor
-
visitFieldInsn
public void visitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor)
- Overrides:
visitFieldInsn
in classorg.objectweb.asm.MethodVisitor
-
visitMethodInsn
public void visitMethodInsn(int opcodeAndSource, java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
- Overrides:
visitMethodInsn
in classorg.objectweb.asm.MethodVisitor
-
visitInvokeDynamicInsn
public void visitInvokeDynamicInsn(java.lang.String name, java.lang.String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)
- Overrides:
visitInvokeDynamicInsn
in classorg.objectweb.asm.MethodVisitor
-
visitJumpInsn
public void visitJumpInsn(int opcode, org.objectweb.asm.Label label)
- Overrides:
visitJumpInsn
in classorg.objectweb.asm.MethodVisitor
-
visitLabel
public void visitLabel(org.objectweb.asm.Label label)
- Overrides:
visitLabel
in classorg.objectweb.asm.MethodVisitor
-
visitLdcInsn
public void visitLdcInsn(java.lang.Object value)
- Overrides:
visitLdcInsn
in classorg.objectweb.asm.MethodVisitor
-
visitIincInsn
public void visitIincInsn(int var, int increment)
- Overrides:
visitIincInsn
in classorg.objectweb.asm.MethodVisitor
-
visitTableSwitchInsn
public void visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)
- Overrides:
visitTableSwitchInsn
in classorg.objectweb.asm.MethodVisitor
-
visitLookupSwitchInsn
public void visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
- Overrides:
visitLookupSwitchInsn
in classorg.objectweb.asm.MethodVisitor
-
visitMultiANewArrayInsn
public void visitMultiANewArrayInsn(java.lang.String descriptor, int numDimensions)
- Overrides:
visitMultiANewArrayInsn
in classorg.objectweb.asm.MethodVisitor
-
nop
public void nop()
Generates a nop instruction.
-
aconst
public void aconst(java.lang.Object value)
Generates the instruction to push the given value on the stack.- Parameters:
value
- the constant to be pushed on the stack. This parameter must be anInteger
, aFloat
, aLong
, aDouble
, aString
, aType
of OBJECT or ARRAY sort for.class
constants, for classes whose version is 49, aType
of METHOD sort for MethodType, aHandle
for MethodHandle constants, for classes whose version is 51 or aConstantDynamic
for a constant dynamic for classes whose version is 55.
-
iconst
public void iconst(int intValue)
Generates the instruction to push the given value on the stack.- Parameters:
intValue
- the constant to be pushed on the stack.
-
lconst
public void lconst(long longValue)
Generates the instruction to push the given value on the stack.- Parameters:
longValue
- the constant to be pushed on the stack.
-
fconst
public void fconst(float floatValue)
Generates the instruction to push the given value on the stack.- Parameters:
floatValue
- the constant to be pushed on the stack.
-
dconst
public void dconst(double doubleValue)
Generates the instruction to push the given value on the stack.- Parameters:
doubleValue
- the constant to be pushed on the stack.
-
tconst
public void tconst(org.objectweb.asm.Type type)
Generates the instruction to push the given type on the stack.- Parameters:
type
- the type to be pushed on the stack.
-
hconst
public void hconst(org.objectweb.asm.Handle handle)
Generates the instruction to push the given handle on the stack.- Parameters:
handle
- the handle to be pushed on the stack.
-
cconst
public void cconst(org.objectweb.asm.ConstantDynamic constantDynamic)
Generates the instruction to push the given constant dynamic on the stack.- Parameters:
constantDynamic
- the constant dynamic to be pushed on the stack.
-
load
public void load(int var, org.objectweb.asm.Type type)
-
aload
public void aload(org.objectweb.asm.Type type)
-
store
public void store(int var, org.objectweb.asm.Type type)
-
astore
public void astore(org.objectweb.asm.Type type)
-
pop
public void pop()
-
pop2
public void pop2()
-
dup
public void dup()
-
dup2
public void dup2()
-
dupX1
public void dupX1()
-
dupX2
public void dupX2()
-
dup2X1
public void dup2X1()
-
dup2X2
public void dup2X2()
-
swap
public void swap()
-
add
public void add(org.objectweb.asm.Type type)
-
sub
public void sub(org.objectweb.asm.Type type)
-
mul
public void mul(org.objectweb.asm.Type type)
-
div
public void div(org.objectweb.asm.Type type)
-
rem
public void rem(org.objectweb.asm.Type type)
-
neg
public void neg(org.objectweb.asm.Type type)
-
shl
public void shl(org.objectweb.asm.Type type)
-
shr
public void shr(org.objectweb.asm.Type type)
-
ushr
public void ushr(org.objectweb.asm.Type type)
-
and
public void and(org.objectweb.asm.Type type)
-
or
public void or(org.objectweb.asm.Type type)
-
xor
public void xor(org.objectweb.asm.Type type)
-
iinc
public void iinc(int var, int increment)
-
cast
public void cast(org.objectweb.asm.Type from, org.objectweb.asm.Type to)
Generates the instruction to cast from the first given type to the other.- Parameters:
from
- a Type.to
- a Type.
-
lcmp
public void lcmp()
-
cmpl
public void cmpl(org.objectweb.asm.Type type)
-
cmpg
public void cmpg(org.objectweb.asm.Type type)
-
ifeq
public void ifeq(org.objectweb.asm.Label label)
-
ifne
public void ifne(org.objectweb.asm.Label label)
-
iflt
public void iflt(org.objectweb.asm.Label label)
-
ifge
public void ifge(org.objectweb.asm.Label label)
-
ifgt
public void ifgt(org.objectweb.asm.Label label)
-
ifle
public void ifle(org.objectweb.asm.Label label)
-
ificmpeq
public void ificmpeq(org.objectweb.asm.Label label)
-
ificmpne
public void ificmpne(org.objectweb.asm.Label label)
-
ificmplt
public void ificmplt(org.objectweb.asm.Label label)
-
ificmpge
public void ificmpge(org.objectweb.asm.Label label)
-
ificmpgt
public void ificmpgt(org.objectweb.asm.Label label)
-
ificmple
public void ificmple(org.objectweb.asm.Label label)
-
ifacmpeq
public void ifacmpeq(org.objectweb.asm.Label label)
-
ifacmpne
public void ifacmpne(org.objectweb.asm.Label label)
-
goTo
public void goTo(org.objectweb.asm.Label label)
-
jsr
public void jsr(org.objectweb.asm.Label label)
-
ret
public void ret(int var)
-
tableswitch
public void tableswitch(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)
-
lookupswitch
public void lookupswitch(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
-
areturn
public void areturn(org.objectweb.asm.Type type)
-
getstatic
public void getstatic(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
-
putstatic
public void putstatic(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
-
getfield
public void getfield(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
-
putfield
public void putfield(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
-
invokevirtual
@Deprecated public void invokevirtual(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
Deprecated.useinvokevirtual(String, String, String, boolean)
instead.Deprecated.- Parameters:
owner
- the internal name of the method's owner class.name
- the method's name.descriptor
- the method's descriptor (seeType
).
-
invokevirtual
public void invokevirtual(java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
Generates the instruction to call the given virtual method.- Parameters:
owner
- the internal name of the method's owner class (seeType.getInternalName()
).name
- the method's name.descriptor
- the method's descriptor (seeType
).isInterface
- if the method's owner class is an interface.
-
invokespecial
@Deprecated public void invokespecial(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
Deprecated.useinvokespecial(String, String, String, boolean)
instead.Deprecated.- Parameters:
owner
- the internal name of the method's owner class.name
- the method's name.descriptor
- the method's descriptor (seeType
).
-
invokespecial
public void invokespecial(java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
Generates the instruction to call the given special method.- Parameters:
owner
- the internal name of the method's owner class (seeType.getInternalName()
).name
- the method's name.descriptor
- the method's descriptor (seeType
).isInterface
- if the method's owner class is an interface.
-
invokestatic
@Deprecated public void invokestatic(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
Deprecated.useinvokestatic(String, String, String, boolean)
instead.Deprecated.- Parameters:
owner
- the internal name of the method's owner class.name
- the method's name.descriptor
- the method's descriptor (seeType
).
-
invokestatic
public void invokestatic(java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
Generates the instruction to call the given static method.- Parameters:
owner
- the internal name of the method's owner class (seeType.getInternalName()
).name
- the method's name.descriptor
- the method's descriptor (seeType
).isInterface
- if the method's owner class is an interface.
-
invokeinterface
public void invokeinterface(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
Generates the instruction to call the given interface method.- Parameters:
owner
- the internal name of the method's owner class (seeType.getInternalName()
).name
- the method's name.descriptor
- the method's descriptor (seeType
).
-
invokedynamic
public void invokedynamic(java.lang.String name, java.lang.String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, java.lang.Object[] bootstrapMethodArguments)
Generates the instruction to call the given dynamic method.- Parameters:
name
- the method's name.descriptor
- the method's descriptor (seeType
).bootstrapMethodHandle
- the bootstrap method.bootstrapMethodArguments
- the bootstrap method constant arguments. Each argument must be anInteger
,Float
,Long
,Double
,String
,Type
,Handle
orConstantDynamic
value. This method is allowed to modify the content of the array so a caller should expect that this array may change.
-
anew
public void anew(org.objectweb.asm.Type type)
-
newarray
public void newarray(org.objectweb.asm.Type type)
Generates the instruction to create and push on the stack an array of the given type.- Parameters:
type
- an array Type.
-
arraylength
public void arraylength()
-
athrow
public void athrow()
-
checkcast
public void checkcast(org.objectweb.asm.Type type)
-
instanceOf
public void instanceOf(org.objectweb.asm.Type type)
-
monitorenter
public void monitorenter()
-
monitorexit
public void monitorexit()
-
multianewarray
public void multianewarray(java.lang.String descriptor, int numDimensions)
-
ifnull
public void ifnull(org.objectweb.asm.Label label)
-
ifnonnull
public void ifnonnull(org.objectweb.asm.Label label)
-
mark
public void mark(org.objectweb.asm.Label label)
-
-