public class CheckMethodAdapter
extends org.objectweb.asm.MethodVisitor
MethodVisitor
that checks that its methods are properly used. More precisely this
method adapter checks each instruction individually, i.e., each visit method checks some
preconditions based only on its arguments - such as the fact that the given opcode is
correct for a given visit method. This adapter can also perform some basic data flow checks (more
precisely those that can be performed without the full class hierarchy - see BasicVerifier
). For instance in a method whose signature is
void m (), the invalid instruction IRETURN, or the invalid sequence IADD L2I will be
detected if the data flow checks are enabled. These checks are enabled by using the CheckMethodAdapter(int,String,String,MethodVisitor,Map)
constructor. They are not performed if
any other constructor is used.Modifier and Type | Field and Description |
---|---|
int |
version
The class version number.
|
Modifier | Constructor and Description |
---|---|
protected |
CheckMethodAdapter(int api,
int access,
java.lang.String name,
java.lang.String descriptor,
org.objectweb.asm.MethodVisitor methodVisitor,
java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)
Constructs a new
CheckMethodAdapter object. |
protected |
CheckMethodAdapter(int api,
org.objectweb.asm.MethodVisitor methodVisitor,
java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)
Constructs a new
CheckMethodAdapter object. |
|
CheckMethodAdapter(int access,
java.lang.String name,
java.lang.String descriptor,
org.objectweb.asm.MethodVisitor methodVisitor,
java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)
Constructs a new
CheckMethodAdapter object. |
|
CheckMethodAdapter(org.objectweb.asm.MethodVisitor methodvisitor)
Constructs a new
CheckMethodAdapter object. |
|
CheckMethodAdapter(org.objectweb.asm.MethodVisitor methodVisitor,
java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)
Constructs a new
CheckMethodAdapter object. |
Modifier and Type | Method and Description |
---|---|
void |
visitAnnotableParameterCount(int parameterCount,
boolean visible) |
org.objectweb.asm.AnnotationVisitor |
visitAnnotation(java.lang.String descriptor,
boolean visible) |
org.objectweb.asm.AnnotationVisitor |
visitAnnotationDefault() |
void |
visitAttribute(org.objectweb.asm.Attribute attribute) |
void |
visitCode() |
void |
visitEnd() |
void |
visitFieldInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String descriptor) |
void |
visitFrame(int type,
int nLocal,
java.lang.Object[] local,
int nStack,
java.lang.Object[] stack) |
void |
visitIincInsn(int var,
int increment) |
void |
visitInsn(int opcode) |
org.objectweb.asm.AnnotationVisitor |
visitInsnAnnotation(int typeRef,
org.objectweb.asm.TypePath typePath,
java.lang.String descriptor,
boolean visible) |
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 |
visitLineNumber(int line,
org.objectweb.asm.Label start) |
void |
visitLocalVariable(java.lang.String name,
java.lang.String descriptor,
java.lang.String signature,
org.objectweb.asm.Label start,
org.objectweb.asm.Label end,
int index) |
org.objectweb.asm.AnnotationVisitor |
visitLocalVariableAnnotation(int typeRef,
org.objectweb.asm.TypePath typePath,
org.objectweb.asm.Label[] start,
org.objectweb.asm.Label[] end,
int[] index,
java.lang.String descriptor,
boolean visible) |
void |
visitLookupSwitchInsn(org.objectweb.asm.Label dflt,
int[] keys,
org.objectweb.asm.Label[] labels) |
void |
visitMaxs(int maxStack,
int maxLocals) |
void |
visitMethodInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String descriptor)
Deprecated.
|
void |
visitMethodInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String descriptor,
boolean isInterface) |
void |
visitMultiANewArrayInsn(java.lang.String descriptor,
int numDimensions) |
void |
visitParameter(java.lang.String name,
int access) |
org.objectweb.asm.AnnotationVisitor |
visitParameterAnnotation(int parameter,
java.lang.String descriptor,
boolean visible) |
void |
visitTableSwitchInsn(int min,
int max,
org.objectweb.asm.Label dflt,
org.objectweb.asm.Label... labels) |
org.objectweb.asm.AnnotationVisitor |
visitTryCatchAnnotation(int typeRef,
org.objectweb.asm.TypePath typePath,
java.lang.String descriptor,
boolean visible) |
void |
visitTryCatchBlock(org.objectweb.asm.Label start,
org.objectweb.asm.Label end,
org.objectweb.asm.Label handler,
java.lang.String type) |
org.objectweb.asm.AnnotationVisitor |
visitTypeAnnotation(int typeRef,
org.objectweb.asm.TypePath typePath,
java.lang.String descriptor,
boolean visible) |
void |
visitTypeInsn(int opcode,
java.lang.String type) |
void |
visitVarInsn(int opcode,
int var) |
public CheckMethodAdapter(org.objectweb.asm.MethodVisitor methodvisitor)
CheckMethodAdapter
object. This method adapter will not perform any
data flow check (see CheckMethodAdapter(int,String,String,MethodVisitor,Map)
).
Subclasses must not use this constructor. Instead, they must use the CheckMethodAdapter(int, MethodVisitor, Map)
version.methodvisitor
- the method visitor to which this adapter must delegate calls.public CheckMethodAdapter(org.objectweb.asm.MethodVisitor methodVisitor, java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)
CheckMethodAdapter
object. This method adapter will not perform any
data flow check (see CheckMethodAdapter(int,String,String,MethodVisitor,Map)
).
Subclasses must not use this constructor. Instead, they must use the CheckMethodAdapter(int, MethodVisitor, Map)
version.methodVisitor
- the method visitor to which this adapter must delegate calls.labelInsnIndices
- the index of the instruction designated by each visited label so far
(in other methods). This map is updated with the labels from the visited method.java.lang.IllegalStateException
- If a subclass calls this constructor.protected CheckMethodAdapter(int api, org.objectweb.asm.MethodVisitor methodVisitor, java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)
CheckMethodAdapter
object. This method adapter will not perform any
data flow check (see CheckMethodAdapter(int,String,String,MethodVisitor,Map)
).api
- the ASM API version implemented by this CheckMethodAdapter. Must be one of Opcodes.ASM4
, Opcodes.ASM5
or Opcodes.ASM6
.methodVisitor
- the method visitor to which this adapter must delegate calls.labelInsnIndices
- the index of the instruction designated by each visited label so far
(in other methods). This map is updated with the labels from the visited method.public CheckMethodAdapter(int access, java.lang.String name, java.lang.String descriptor, org.objectweb.asm.MethodVisitor methodVisitor, java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)
CheckMethodAdapter
object. This method adapter will perform basic data
flow checks. For instance in a method whose signature is void m (), the invalid
instruction IRETURN, or the invalid sequence IADD L2I will be detected. Subclasses must not
use this constructor. Instead, they must use the CheckMethodAdapter(int,int,String,String,MethodVisitor,Map)
version.access
- the method's access flags.name
- the method's name.descriptor
- the method's descriptor (see Type
).methodVisitor
- the method visitor to which this adapter must delegate calls.labelInsnIndices
- the index of the instruction designated by each visited label so far
(in other methods). This map is updated with the labels from the visited method.protected CheckMethodAdapter(int api, int access, java.lang.String name, java.lang.String descriptor, org.objectweb.asm.MethodVisitor methodVisitor, java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)
CheckMethodAdapter
object. This method adapter will perform basic data
flow checks. For instance in a method whose signature is void m (), the invalid
instruction IRETURN, or the invalid sequence IADD L2I will be detected.api
- the ASM API version implemented by this CheckMethodAdapter. Must be one of Opcodes.ASM4
, Opcodes.ASM5
or Opcodes.ASM6
.access
- the method's access flags.name
- the method's name.descriptor
- the method's descriptor (see Type
).methodVisitor
- the method visitor to which this adapter must delegate calls.labelInsnIndices
- the index of the instruction designated by each visited label so far
(in other methods). This map is updated with the labels from the visited method.public void visitParameter(java.lang.String name, int access)
visitParameter
in class org.objectweb.asm.MethodVisitor
public org.objectweb.asm.AnnotationVisitor visitAnnotation(java.lang.String descriptor, boolean visible)
visitAnnotation
in class org.objectweb.asm.MethodVisitor
public org.objectweb.asm.AnnotationVisitor visitTypeAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)
visitTypeAnnotation
in class org.objectweb.asm.MethodVisitor
public org.objectweb.asm.AnnotationVisitor visitAnnotationDefault()
visitAnnotationDefault
in class org.objectweb.asm.MethodVisitor
public void visitAnnotableParameterCount(int parameterCount, boolean visible)
visitAnnotableParameterCount
in class org.objectweb.asm.MethodVisitor
public org.objectweb.asm.AnnotationVisitor visitParameterAnnotation(int parameter, java.lang.String descriptor, boolean visible)
visitParameterAnnotation
in class org.objectweb.asm.MethodVisitor
public void visitAttribute(org.objectweb.asm.Attribute attribute)
visitAttribute
in class org.objectweb.asm.MethodVisitor
public void visitCode()
visitCode
in class org.objectweb.asm.MethodVisitor
public void visitFrame(int type, int nLocal, java.lang.Object[] local, int nStack, java.lang.Object[] stack)
visitFrame
in class org.objectweb.asm.MethodVisitor
public void visitInsn(int opcode)
visitInsn
in class org.objectweb.asm.MethodVisitor
public void visitIntInsn(int opcode, int operand)
visitIntInsn
in class org.objectweb.asm.MethodVisitor
public void visitVarInsn(int opcode, int var)
visitVarInsn
in class org.objectweb.asm.MethodVisitor
public void visitTypeInsn(int opcode, java.lang.String type)
visitTypeInsn
in class org.objectweb.asm.MethodVisitor
public void visitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor)
visitFieldInsn
in class org.objectweb.asm.MethodVisitor
@Deprecated public void visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor)
visitMethodInsn
in class org.objectweb.asm.MethodVisitor
public void visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
visitMethodInsn
in class org.objectweb.asm.MethodVisitor
public void visitInvokeDynamicInsn(java.lang.String name, java.lang.String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)
visitInvokeDynamicInsn
in class org.objectweb.asm.MethodVisitor
public void visitJumpInsn(int opcode, org.objectweb.asm.Label label)
visitJumpInsn
in class org.objectweb.asm.MethodVisitor
public void visitLabel(org.objectweb.asm.Label label)
visitLabel
in class org.objectweb.asm.MethodVisitor
public void visitLdcInsn(java.lang.Object value)
visitLdcInsn
in class org.objectweb.asm.MethodVisitor
public void visitIincInsn(int var, int increment)
visitIincInsn
in class org.objectweb.asm.MethodVisitor
public void visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)
visitTableSwitchInsn
in class org.objectweb.asm.MethodVisitor
public void visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
visitLookupSwitchInsn
in class org.objectweb.asm.MethodVisitor
public void visitMultiANewArrayInsn(java.lang.String descriptor, int numDimensions)
visitMultiANewArrayInsn
in class org.objectweb.asm.MethodVisitor
public org.objectweb.asm.AnnotationVisitor visitInsnAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)
visitInsnAnnotation
in class org.objectweb.asm.MethodVisitor
public void visitTryCatchBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, java.lang.String type)
visitTryCatchBlock
in class org.objectweb.asm.MethodVisitor
public org.objectweb.asm.AnnotationVisitor visitTryCatchAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)
visitTryCatchAnnotation
in class org.objectweb.asm.MethodVisitor
public void visitLocalVariable(java.lang.String name, java.lang.String descriptor, java.lang.String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int index)
visitLocalVariable
in class org.objectweb.asm.MethodVisitor
public org.objectweb.asm.AnnotationVisitor visitLocalVariableAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, org.objectweb.asm.Label[] start, org.objectweb.asm.Label[] end, int[] index, java.lang.String descriptor, boolean visible)
visitLocalVariableAnnotation
in class org.objectweb.asm.MethodVisitor
public void visitLineNumber(int line, org.objectweb.asm.Label start)
visitLineNumber
in class org.objectweb.asm.MethodVisitor
public void visitMaxs(int maxStack, int maxLocals)
visitMaxs
in class org.objectweb.asm.MethodVisitor
public void visitEnd()
visitEnd
in class org.objectweb.asm.MethodVisitor