Package org.objectweb.asm.util
Class CheckMethodAdapter
- java.lang.Object
-
- org.objectweb.asm.MethodVisitor
-
- org.objectweb.asm.util.CheckMethodAdapter
-
public class CheckMethodAdapter extends org.objectweb.asm.MethodVisitorAMethodVisitorthat 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 - seeBasicVerifier). For instance in a method whose signature isvoid 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 theCheckMethodAdapter(int,String,String,MethodVisitor,Map)constructor. They are not performed if any other constructor is used.
-
-
Field Summary
Fields Modifier and Type Field Description intversionThe class version number.
-
Constructor Summary
Constructors Modifier Constructor Description protectedCheckMethodAdapter(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 newCheckMethodAdapterobject.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 newCheckMethodAdapterobject.protectedCheckMethodAdapter(int api, org.objectweb.asm.MethodVisitor methodVisitor, java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)Constructs a newCheckMethodAdapterobject.CheckMethodAdapter(org.objectweb.asm.MethodVisitor methodvisitor)Constructs a newCheckMethodAdapterobject.CheckMethodAdapter(org.objectweb.asm.MethodVisitor methodVisitor, java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)Constructs a newCheckMethodAdapterobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidvisitAnnotableParameterCount(int parameterCount, boolean visible)org.objectweb.asm.AnnotationVisitorvisitAnnotation(java.lang.String descriptor, boolean visible)org.objectweb.asm.AnnotationVisitorvisitAnnotationDefault()voidvisitAttribute(org.objectweb.asm.Attribute attribute)voidvisitCode()voidvisitEnd()voidvisitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor)voidvisitFrame(int type, int numLocal, java.lang.Object[] local, int numStack, java.lang.Object[] stack)voidvisitIincInsn(int varIndex, int increment)voidvisitInsn(int opcode)org.objectweb.asm.AnnotationVisitorvisitInsnAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)voidvisitIntInsn(int opcode, int operand)voidvisitInvokeDynamicInsn(java.lang.String name, java.lang.String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)voidvisitJumpInsn(int opcode, org.objectweb.asm.Label label)voidvisitLabel(org.objectweb.asm.Label label)voidvisitLdcInsn(java.lang.Object value)voidvisitLineNumber(int line, org.objectweb.asm.Label start)voidvisitLocalVariable(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.AnnotationVisitorvisitLocalVariableAnnotation(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)voidvisitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)voidvisitMaxs(int maxStack, int maxLocals)voidvisitMethodInsn(int opcodeAndSource, java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)voidvisitMultiANewArrayInsn(java.lang.String descriptor, int numDimensions)voidvisitParameter(java.lang.String name, int access)org.objectweb.asm.AnnotationVisitorvisitParameterAnnotation(int parameter, java.lang.String descriptor, boolean visible)voidvisitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)org.objectweb.asm.AnnotationVisitorvisitTryCatchAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)voidvisitTryCatchBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, java.lang.String type)org.objectweb.asm.AnnotationVisitorvisitTypeAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)voidvisitTypeInsn(int opcode, java.lang.String type)voidvisitVarInsn(int opcode, int varIndex)
-
-
-
Constructor Detail
-
CheckMethodAdapter
public CheckMethodAdapter(org.objectweb.asm.MethodVisitor methodvisitor)
Constructs a newCheckMethodAdapterobject. This method adapter will not perform any data flow check (seeCheckMethodAdapter(int,String,String,MethodVisitor,Map)). Subclasses must not use this constructor. Instead, they must use theCheckMethodAdapter(int, MethodVisitor, Map)version.- Parameters:
methodvisitor- the method visitor to which this adapter must delegate calls.
-
CheckMethodAdapter
public CheckMethodAdapter(org.objectweb.asm.MethodVisitor methodVisitor, java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)Constructs a newCheckMethodAdapterobject. This method adapter will not perform any data flow check (seeCheckMethodAdapter(int,String,String,MethodVisitor,Map)). Subclasses must not use this constructor. Instead, they must use theCheckMethodAdapter(int, MethodVisitor, Map)version.- Parameters:
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.- Throws:
java.lang.IllegalStateException- If a subclass calls this constructor.
-
CheckMethodAdapter
protected CheckMethodAdapter(int api, org.objectweb.asm.MethodVisitor methodVisitor, java.util.Map<org.objectweb.asm.Label,java.lang.Integer> labelInsnIndices)Constructs a newCheckMethodAdapterobject. This method adapter will not perform any data flow check (seeCheckMethodAdapter(int,String,String,MethodVisitor,Map)).- Parameters:
api- the ASM API version implemented by this CheckMethodAdapter. Must be one of theASMx values inOpcodes.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.
-
CheckMethodAdapter
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)Constructs a newCheckMethodAdapterobject. This method adapter will perform basic data flow checks. For instance in a method whose signature isvoid m (), the invalid instruction IRETURN, or the invalid sequence IADD L2I will be detected. Subclasses must not use this constructor. Instead, they must use theCheckMethodAdapter(int,int,String,String,MethodVisitor,Map)version.- Parameters:
access- the method's access flags.name- the method's name.descriptor- the method's descriptor (seeType).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.
-
CheckMethodAdapter
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 newCheckMethodAdapterobject. This method adapter will perform basic data flow checks. For instance in a method whose signature isvoid m (), the invalid instruction IRETURN, or the invalid sequence IADD L2I will be detected.- Parameters:
api- the ASM API version implemented by this CheckMethodAdapter. Must be one of theASMx values inOpcodes.access- the method's access flags.name- the method's name.descriptor- the method's descriptor (seeType).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.
-
-
Method Detail
-
visitParameter
public void visitParameter(java.lang.String name, int access)- Overrides:
visitParameterin classorg.objectweb.asm.MethodVisitor
-
visitAnnotation
public org.objectweb.asm.AnnotationVisitor visitAnnotation(java.lang.String descriptor, boolean visible)- Overrides:
visitAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitTypeAnnotation
public org.objectweb.asm.AnnotationVisitor visitTypeAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)- Overrides:
visitTypeAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitAnnotationDefault
public org.objectweb.asm.AnnotationVisitor visitAnnotationDefault()
- Overrides:
visitAnnotationDefaultin classorg.objectweb.asm.MethodVisitor
-
visitAnnotableParameterCount
public void visitAnnotableParameterCount(int parameterCount, boolean visible)- Overrides:
visitAnnotableParameterCountin classorg.objectweb.asm.MethodVisitor
-
visitParameterAnnotation
public org.objectweb.asm.AnnotationVisitor visitParameterAnnotation(int parameter, java.lang.String descriptor, boolean visible)- Overrides:
visitParameterAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitAttribute
public void visitAttribute(org.objectweb.asm.Attribute attribute)
- Overrides:
visitAttributein classorg.objectweb.asm.MethodVisitor
-
visitCode
public void visitCode()
- Overrides:
visitCodein classorg.objectweb.asm.MethodVisitor
-
visitFrame
public void visitFrame(int type, int numLocal, java.lang.Object[] local, int numStack, java.lang.Object[] stack)- Overrides:
visitFramein classorg.objectweb.asm.MethodVisitor
-
visitInsn
public void visitInsn(int opcode)
- Overrides:
visitInsnin classorg.objectweb.asm.MethodVisitor
-
visitIntInsn
public void visitIntInsn(int opcode, int operand)- Overrides:
visitIntInsnin classorg.objectweb.asm.MethodVisitor
-
visitVarInsn
public void visitVarInsn(int opcode, int varIndex)- Overrides:
visitVarInsnin classorg.objectweb.asm.MethodVisitor
-
visitTypeInsn
public void visitTypeInsn(int opcode, java.lang.String type)- Overrides:
visitTypeInsnin classorg.objectweb.asm.MethodVisitor
-
visitFieldInsn
public void visitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor)- Overrides:
visitFieldInsnin 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:
visitMethodInsnin 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:
visitInvokeDynamicInsnin classorg.objectweb.asm.MethodVisitor
-
visitJumpInsn
public void visitJumpInsn(int opcode, org.objectweb.asm.Label label)- Overrides:
visitJumpInsnin classorg.objectweb.asm.MethodVisitor
-
visitLabel
public void visitLabel(org.objectweb.asm.Label label)
- Overrides:
visitLabelin classorg.objectweb.asm.MethodVisitor
-
visitLdcInsn
public void visitLdcInsn(java.lang.Object value)
- Overrides:
visitLdcInsnin classorg.objectweb.asm.MethodVisitor
-
visitIincInsn
public void visitIincInsn(int varIndex, int increment)- Overrides:
visitIincInsnin classorg.objectweb.asm.MethodVisitor
-
visitTableSwitchInsn
public void visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)- Overrides:
visitTableSwitchInsnin classorg.objectweb.asm.MethodVisitor
-
visitLookupSwitchInsn
public void visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)- Overrides:
visitLookupSwitchInsnin classorg.objectweb.asm.MethodVisitor
-
visitMultiANewArrayInsn
public void visitMultiANewArrayInsn(java.lang.String descriptor, int numDimensions)- Overrides:
visitMultiANewArrayInsnin classorg.objectweb.asm.MethodVisitor
-
visitInsnAnnotation
public org.objectweb.asm.AnnotationVisitor visitInsnAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)- Overrides:
visitInsnAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitTryCatchBlock
public void visitTryCatchBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, java.lang.String type)- Overrides:
visitTryCatchBlockin classorg.objectweb.asm.MethodVisitor
-
visitTryCatchAnnotation
public org.objectweb.asm.AnnotationVisitor visitTryCatchAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)- Overrides:
visitTryCatchAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitLocalVariable
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)- Overrides:
visitLocalVariablein classorg.objectweb.asm.MethodVisitor
-
visitLocalVariableAnnotation
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)- Overrides:
visitLocalVariableAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitLineNumber
public void visitLineNumber(int line, org.objectweb.asm.Label start)- Overrides:
visitLineNumberin classorg.objectweb.asm.MethodVisitor
-
visitMaxs
public void visitMaxs(int maxStack, int maxLocals)- Overrides:
visitMaxsin classorg.objectweb.asm.MethodVisitor
-
visitEnd
public void visitEnd()
- Overrides:
visitEndin classorg.objectweb.asm.MethodVisitor
-
-