|
Packit |
5e46da |
/***
|
|
Packit |
5e46da |
* ASM: a very small and fast Java bytecode manipulation framework
|
|
Packit |
5e46da |
* Copyright (c) 2000-2011 INRIA, France Telecom
|
|
Packit |
5e46da |
* All rights reserved.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* Redistribution and use in source and binary forms, with or without
|
|
Packit |
5e46da |
* modification, are permitted provided that the following conditions
|
|
Packit |
5e46da |
* are met:
|
|
Packit |
5e46da |
* 1. Redistributions of source code must retain the above copyright
|
|
Packit |
5e46da |
* notice, this list of conditions and the following disclaimer.
|
|
Packit |
5e46da |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
Packit |
5e46da |
* notice, this list of conditions and the following disclaimer in the
|
|
Packit |
5e46da |
* documentation and/or other materials provided with the distribution.
|
|
Packit |
5e46da |
* 3. Neither the name of the copyright holders nor the names of its
|
|
Packit |
5e46da |
* contributors may be used to endorse or promote products derived from
|
|
Packit |
5e46da |
* this software without specific prior written permission.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
5e46da |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
5e46da |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
5e46da |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
Packit |
5e46da |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit |
5e46da |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit |
5e46da |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit |
5e46da |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit |
5e46da |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
5e46da |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
Packit |
5e46da |
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
package org.objectweb.asm;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* A visitor to visit a Java method. The methods of this class must be called in
|
|
Packit |
5e46da |
* the following order: ( <tt>visitParameter</tt> )* [
|
|
Packit |
5e46da |
* <tt>visitAnnotationDefault</tt> ] ( <tt>visitAnnotation</tt> |
|
|
Packit |
5e46da |
* <tt>visitParameterAnnotation</tt> <tt>visitTypeAnnotation</tt> |
|
|
Packit |
5e46da |
* <tt>visitAttribute</tt> )* [ <tt>visitCode</tt> ( <tt>visitFrame</tt> |
|
|
Packit |
5e46da |
* <tt>visitXInsn</tt> | <tt>visitLabel</tt> |
|
|
Packit |
5e46da |
* <tt>visitInsnAnnotation</tt> | <tt>visitTryCatchBlock</tt> |
|
|
Packit |
5e46da |
* <tt>visitTryCatchAnnotation</tt> | <tt>visitLocalVariable</tt> |
|
|
Packit |
5e46da |
* <tt>visitLocalVariableAnnotation</tt> | <tt>visitLineNumber</tt> )*
|
|
Packit |
5e46da |
* <tt>visitMaxs</tt> ] <tt>visitEnd</tt>. In addition, the
|
|
Packit |
5e46da |
* <tt>visitXInsn</tt> and <tt>visitLabel</tt> methods must be called in
|
|
Packit |
5e46da |
* the sequential order of the bytecode instructions of the visited code,
|
|
Packit |
5e46da |
* <tt>visitInsnAnnotation</tt> must be called after the annotated
|
|
Packit |
5e46da |
* instruction, <tt>visitTryCatchBlock</tt> must be called before the
|
|
Packit |
5e46da |
* labels passed as arguments have been visited,
|
|
Packit |
5e46da |
* <tt>visitTryCatchBlockAnnotation</tt> must be called after the
|
|
Packit |
5e46da |
* corresponding try catch block has been visited, and the
|
|
Packit |
5e46da |
* <tt>visitLocalVariable</tt>, <tt>visitLocalVariableAnnotation</tt> and
|
|
Packit |
5e46da |
* <tt>visitLineNumber</tt> methods must be called after the labels
|
|
Packit |
5e46da |
* passed as arguments have been visited.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @author Eric Bruneton
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public abstract class MethodVisitor {
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* The ASM API version implemented by this visitor. The value of this field
|
|
Packit |
5e46da |
* must be one of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
protected final int api;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* The method visitor to which this visitor must delegate method calls. May
|
|
Packit |
5e46da |
* be null.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
protected MethodVisitor mv;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Constructs a new {@link MethodVisitor}.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param api
|
|
Packit |
5e46da |
* the ASM API version implemented by this visitor. Must be one
|
|
Packit |
5e46da |
* of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public MethodVisitor(final int api) {
|
|
Packit |
5e46da |
this(api, null);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Constructs a new {@link MethodVisitor}.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param api
|
|
Packit |
5e46da |
* the ASM API version implemented by this visitor. Must be one
|
|
Packit |
5e46da |
* of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
|
|
Packit |
5e46da |
* @param mv
|
|
Packit |
5e46da |
* the method visitor to which this visitor must delegate method
|
|
Packit |
5e46da |
* calls. May be null.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public MethodVisitor(final int api, final MethodVisitor mv) {
|
|
Packit |
5e46da |
if (api != Opcodes.ASM4 && api != Opcodes.ASM5) {
|
|
Packit |
5e46da |
throw new IllegalArgumentException();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
this.api = api;
|
|
Packit |
5e46da |
this.mv = mv;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
// -------------------------------------------------------------------------
|
|
Packit |
5e46da |
// Parameters, annotations and non standard attributes
|
|
Packit |
5e46da |
// -------------------------------------------------------------------------
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a parameter of this method.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param name
|
|
Packit |
5e46da |
* parameter name or null if none is provided.
|
|
Packit |
5e46da |
* @param access
|
|
Packit |
5e46da |
* the parameter's access flags, only <tt>ACC_FINAL</tt>,
|
|
Packit |
5e46da |
* <tt>ACC_SYNTHETIC</tt> or/and <tt>ACC_MANDATED</tt> are
|
|
Packit |
5e46da |
* allowed (see {@link Opcodes}).
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitParameter(String name, int access) {
|
|
Packit |
5e46da |
if (api < Opcodes.ASM5) {
|
|
Packit |
5e46da |
throw new RuntimeException();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitParameter(name, access);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits the default value of this annotation interface method.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @return a visitor to the visit the actual default value of this
|
|
Packit |
5e46da |
* annotation interface method, or <tt>null</tt> if this visitor is
|
|
Packit |
5e46da |
* not interested in visiting this default value. The 'name'
|
|
Packit |
5e46da |
* parameters passed to the methods of this annotation visitor are
|
|
Packit |
5e46da |
* ignored. Moreover, exacly one visit method must be called on this
|
|
Packit |
5e46da |
* annotation visitor, followed by visitEnd.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public AnnotationVisitor visitAnnotationDefault() {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
return mv.visitAnnotationDefault();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return null;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits an annotation of this method.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* the class descriptor of the annotation class.
|
|
Packit |
5e46da |
* @param visible
|
|
Packit |
5e46da |
* <tt>true</tt> if the annotation is visible at runtime.
|
|
Packit |
5e46da |
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
|
Packit |
5e46da |
* this visitor is not interested in visiting this annotation.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
return mv.visitAnnotation(desc, visible);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return null;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits an annotation on a type in the method signature.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param typeRef
|
|
Packit |
5e46da |
* a reference to the annotated type. The sort of this type
|
|
Packit |
5e46da |
* reference must be {@link TypeReference#METHOD_TYPE_PARAMETER
|
|
Packit |
5e46da |
* METHOD_TYPE_PARAMETER},
|
|
Packit |
5e46da |
* {@link TypeReference#METHOD_TYPE_PARAMETER_BOUND
|
|
Packit |
5e46da |
* METHOD_TYPE_PARAMETER_BOUND},
|
|
Packit |
5e46da |
* {@link TypeReference#METHOD_RETURN METHOD_RETURN},
|
|
Packit |
5e46da |
* {@link TypeReference#METHOD_RECEIVER METHOD_RECEIVER},
|
|
Packit |
5e46da |
* {@link TypeReference#METHOD_FORMAL_PARAMETER
|
|
Packit |
5e46da |
* METHOD_FORMAL_PARAMETER} or {@link TypeReference#THROWS
|
|
Packit |
5e46da |
* THROWS}. See {@link TypeReference}.
|
|
Packit |
5e46da |
* @param typePath
|
|
Packit |
5e46da |
* the path to the annotated type argument, wildcard bound, array
|
|
Packit |
5e46da |
* element type, or static inner type within 'typeRef'. May be
|
|
Packit |
5e46da |
* <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* the class descriptor of the annotation class.
|
|
Packit |
5e46da |
* @param visible
|
|
Packit |
5e46da |
* <tt>true</tt> if the annotation is visible at runtime.
|
|
Packit |
5e46da |
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
|
Packit |
5e46da |
* this visitor is not interested in visiting this annotation.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public AnnotationVisitor visitTypeAnnotation(int typeRef,
|
|
Packit |
5e46da |
TypePath typePath, String desc, boolean visible) {
|
|
Packit |
5e46da |
if (api < Opcodes.ASM5) {
|
|
Packit |
5e46da |
throw new RuntimeException();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
return mv.visitTypeAnnotation(typeRef, typePath, desc, visible);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return null;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits an annotation of a parameter this method.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param parameter
|
|
Packit |
5e46da |
* the parameter index.
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* the class descriptor of the annotation class.
|
|
Packit |
5e46da |
* @param visible
|
|
Packit |
5e46da |
* <tt>true</tt> if the annotation is visible at runtime.
|
|
Packit |
5e46da |
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
|
Packit |
5e46da |
* this visitor is not interested in visiting this annotation.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public AnnotationVisitor visitParameterAnnotation(int parameter,
|
|
Packit |
5e46da |
String desc, boolean visible) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
return mv.visitParameterAnnotation(parameter, desc, visible);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return null;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a non standard attribute of this method.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param attr
|
|
Packit |
5e46da |
* an attribute.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitAttribute(Attribute attr) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitAttribute(attr);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Starts the visit of the method's code, if any (i.e. non abstract method).
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitCode() {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitCode();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits the current state of the local variables and operand stack
|
|
Packit |
5e46da |
* elements. This method must(*) be called just before any
|
|
Packit |
5e46da |
* instruction i that follows an unconditional branch instruction
|
|
Packit |
5e46da |
* such as GOTO or THROW, that is the target of a jump instruction, or that
|
|
Packit |
5e46da |
* starts an exception handler block. The visited types must describe the
|
|
Packit |
5e46da |
* values of the local variables and of the operand stack elements just
|
|
Packit |
5e46da |
* before i is executed.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* (*) this is mandatory only for classes whose version is greater than or
|
|
Packit |
5e46da |
* equal to {@link Opcodes#V1_6 V1_6}.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* The frames of a method must be given either in expanded form, or in
|
|
Packit |
5e46da |
* compressed form (all frames must use the same format, i.e. you must not
|
|
Packit |
5e46da |
* mix expanded and compressed frames within a single method):
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* In expanded form, all frames must have the F_NEW type.
|
|
Packit |
5e46da |
* In compressed form, frames are basically "deltas" from the state of
|
|
Packit |
5e46da |
* the previous frame:
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* {@link Opcodes#F_SAME} representing frame with exactly the same
|
|
Packit |
5e46da |
* locals as the previous frame and with the empty stack.
|
|
Packit |
5e46da |
* {@link Opcodes#F_SAME1} representing frame with exactly the same
|
|
Packit |
5e46da |
* locals as the previous frame and with single value on the stack (
|
|
Packit |
5e46da |
* nStack is 1 and stack[0] contains value for the
|
|
Packit |
5e46da |
* type of the stack item).
|
|
Packit |
5e46da |
* {@link Opcodes#F_APPEND} representing frame with current locals are
|
|
Packit |
5e46da |
* the same as the locals in the previous frame, except that additional
|
|
Packit |
5e46da |
* locals are defined (nLocal is 1, 2 or 3 and
|
|
Packit |
5e46da |
* local elements contains values representing added types).
|
|
Packit |
5e46da |
* {@link Opcodes#F_CHOP} representing frame with current locals are the
|
|
Packit |
5e46da |
* same as the locals in the previous frame, except that the last 1-3 locals
|
|
Packit |
5e46da |
* are absent and with the empty stack (nLocals is 1, 2 or 3).
|
|
Packit |
5e46da |
* {@link Opcodes#F_FULL} representing complete frame data.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* In both cases the first frame, corresponding to the method's parameters
|
|
Packit |
5e46da |
* and access flags, is implicit and must not be visited. Also, it is
|
|
Packit |
5e46da |
* illegal to visit two or more frames for the same code location (i.e., at
|
|
Packit |
5e46da |
* least one instruction must be visited between two calls to visitFrame).
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param type
|
|
Packit |
5e46da |
* the type of this stack map frame. Must be
|
|
Packit |
5e46da |
* {@link Opcodes#F_NEW} for expanded frames, or
|
|
Packit |
5e46da |
* {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND},
|
|
Packit |
5e46da |
* {@link Opcodes#F_CHOP}, {@link Opcodes#F_SAME} or
|
|
Packit |
5e46da |
* {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for
|
|
Packit |
5e46da |
* compressed frames.
|
|
Packit |
5e46da |
* @param nLocal
|
|
Packit |
5e46da |
* the number of local variables in the visited frame.
|
|
Packit |
5e46da |
* @param local
|
|
Packit |
5e46da |
* the local variable types in this frame. This array must not be
|
|
Packit |
5e46da |
* modified. Primitive types are represented by
|
|
Packit |
5e46da |
* {@link Opcodes#TOP}, {@link Opcodes#INTEGER},
|
|
Packit |
5e46da |
* {@link Opcodes#FLOAT}, {@link Opcodes#LONG},
|
|
Packit |
5e46da |
* {@link Opcodes#DOUBLE},{@link Opcodes#NULL} or
|
|
Packit |
5e46da |
* {@link Opcodes#UNINITIALIZED_THIS} (long and double are
|
|
Packit |
5e46da |
* represented by a single element). Reference types are
|
|
Packit |
5e46da |
* represented by String objects (representing internal names),
|
|
Packit |
5e46da |
* and uninitialized types by Label objects (this label
|
|
Packit |
5e46da |
* designates the NEW instruction that created this uninitialized
|
|
Packit |
5e46da |
* value).
|
|
Packit |
5e46da |
* @param nStack
|
|
Packit |
5e46da |
* the number of operand stack elements in the visited frame.
|
|
Packit |
5e46da |
* @param stack
|
|
Packit |
5e46da |
* the operand stack types in this frame. This array must not be
|
|
Packit |
5e46da |
* modified. Its content has the same format as the "local"
|
|
Packit |
5e46da |
* array.
|
|
Packit |
5e46da |
* @throws IllegalStateException
|
|
Packit |
5e46da |
* if a frame is visited just after another one, without any
|
|
Packit |
5e46da |
* instruction between the two (unless this frame is a
|
|
Packit |
5e46da |
* Opcodes#F_SAME frame, in which case it is silently ignored).
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitFrame(int type, int nLocal, Object[] local, int nStack,
|
|
Packit |
5e46da |
Object[] stack) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitFrame(type, nLocal, local, nStack, stack);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
// -------------------------------------------------------------------------
|
|
Packit |
5e46da |
// Normal instructions
|
|
Packit |
5e46da |
// -------------------------------------------------------------------------
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a zero operand instruction.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param opcode
|
|
Packit |
5e46da |
* the opcode of the instruction to be visited. This opcode is
|
|
Packit |
5e46da |
* either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1,
|
|
Packit |
5e46da |
* ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1,
|
|
Packit |
5e46da |
* FCONST_0, FCONST_1, FCONST_2, DCONST_0, DCONST_1, IALOAD,
|
|
Packit |
5e46da |
* LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD,
|
|
Packit |
5e46da |
* IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE,
|
|
Packit |
5e46da |
* SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1,
|
|
Packit |
5e46da |
* DUP2_X2, SWAP, IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB,
|
|
Packit |
5e46da |
* IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM,
|
|
Packit |
5e46da |
* FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR,
|
|
Packit |
5e46da |
* IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, I2L, I2F, I2D,
|
|
Packit |
5e46da |
* L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S,
|
|
Packit |
5e46da |
* LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN, FRETURN,
|
|
Packit |
5e46da |
* DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, MONITORENTER,
|
|
Packit |
5e46da |
* or MONITOREXIT.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitInsn(int opcode) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitInsn(opcode);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits an instruction with a single int operand.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param opcode
|
|
Packit |
5e46da |
* the opcode of the instruction to be visited. This opcode is
|
|
Packit |
5e46da |
* either BIPUSH, SIPUSH or NEWARRAY.
|
|
Packit |
5e46da |
* @param operand
|
|
Packit |
5e46da |
* the operand of the instruction to be visited.
|
|
Packit |
5e46da |
* When opcode is BIPUSH, operand value should be between
|
|
Packit |
5e46da |
* Byte.MIN_VALUE and Byte.MAX_VALUE.
|
|
Packit |
5e46da |
* When opcode is SIPUSH, operand value should be between
|
|
Packit |
5e46da |
* Short.MIN_VALUE and Short.MAX_VALUE.
|
|
Packit |
5e46da |
* When opcode is NEWARRAY, operand value should be one of
|
|
Packit |
5e46da |
* {@link Opcodes#T_BOOLEAN}, {@link Opcodes#T_CHAR},
|
|
Packit |
5e46da |
* {@link Opcodes#T_FLOAT}, {@link Opcodes#T_DOUBLE},
|
|
Packit |
5e46da |
* {@link Opcodes#T_BYTE}, {@link Opcodes#T_SHORT},
|
|
Packit |
5e46da |
* {@link Opcodes#T_INT} or {@link Opcodes#T_LONG}.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitIntInsn(int opcode, int operand) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitIntInsn(opcode, operand);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a local variable instruction. A local variable instruction is an
|
|
Packit |
5e46da |
* instruction that loads or stores the value of a local variable.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param opcode
|
|
Packit |
5e46da |
* the opcode of the local variable instruction to be visited.
|
|
Packit |
5e46da |
* This opcode is either ILOAD, LLOAD, FLOAD, DLOAD, ALOAD,
|
|
Packit |
5e46da |
* ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.
|
|
Packit |
5e46da |
* @param var
|
|
Packit |
5e46da |
* the operand of the instruction to be visited. This operand is
|
|
Packit |
5e46da |
* the index of a local variable.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitVarInsn(int opcode, int var) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitVarInsn(opcode, var);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a type instruction. A type instruction is an instruction that
|
|
Packit |
5e46da |
* takes the internal name of a class as parameter.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param opcode
|
|
Packit |
5e46da |
* the opcode of the type instruction to be visited. This opcode
|
|
Packit |
5e46da |
* is either NEW, ANEWARRAY, CHECKCAST or INSTANCEOF.
|
|
Packit |
5e46da |
* @param type
|
|
Packit |
5e46da |
* the operand of the instruction to be visited. This operand
|
|
Packit |
5e46da |
* must be the internal name of an object or array class (see
|
|
Packit |
5e46da |
* {@link Type#getInternalName() getInternalName}).
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitTypeInsn(int opcode, String type) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitTypeInsn(opcode, type);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a field instruction. A field instruction is an instruction that
|
|
Packit |
5e46da |
* loads or stores the value of a field of an object.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param opcode
|
|
Packit |
5e46da |
* the opcode of the type instruction to be visited. This opcode
|
|
Packit |
5e46da |
* is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
|
|
Packit |
5e46da |
* @param owner
|
|
Packit |
5e46da |
* the internal name of the field's owner class (see
|
|
Packit |
5e46da |
* {@link Type#getInternalName() getInternalName}).
|
|
Packit |
5e46da |
* @param name
|
|
Packit |
5e46da |
* the field's name.
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* the field's descriptor (see {@link Type Type}).
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitFieldInsn(int opcode, String owner, String name,
|
|
Packit |
5e46da |
String desc) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitFieldInsn(opcode, owner, name, desc);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a method instruction. A method instruction is an instruction that
|
|
Packit |
5e46da |
* invokes a method.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param opcode
|
|
Packit |
5e46da |
* the opcode of the type instruction to be visited. This opcode
|
|
Packit |
5e46da |
* is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
|
|
Packit |
5e46da |
* INVOKEINTERFACE.
|
|
Packit |
5e46da |
* @param owner
|
|
Packit |
5e46da |
* the internal name of the method's owner class (see
|
|
Packit |
5e46da |
* {@link Type#getInternalName() getInternalName}).
|
|
Packit |
5e46da |
* @param name
|
|
Packit |
5e46da |
* the method's name.
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* the method's descriptor (see {@link Type Type}).
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
@Deprecated
|
|
Packit |
5e46da |
public void visitMethodInsn(int opcode, String owner, String name,
|
|
Packit |
5e46da |
String desc) {
|
|
Packit |
5e46da |
if (api >= Opcodes.ASM5) {
|
|
Packit |
5e46da |
boolean itf = opcode == Opcodes.INVOKEINTERFACE;
|
|
Packit |
5e46da |
visitMethodInsn(opcode, owner, name, desc, itf);
|
|
Packit |
5e46da |
return;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitMethodInsn(opcode, owner, name, desc);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a method instruction. A method instruction is an instruction that
|
|
Packit |
5e46da |
* invokes a method.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param opcode
|
|
Packit |
5e46da |
* the opcode of the type instruction to be visited. This opcode
|
|
Packit |
5e46da |
* is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
|
|
Packit |
5e46da |
* INVOKEINTERFACE.
|
|
Packit |
5e46da |
* @param owner
|
|
Packit |
5e46da |
* the internal name of the method's owner class (see
|
|
Packit |
5e46da |
* {@link Type#getInternalName() getInternalName}).
|
|
Packit |
5e46da |
* @param name
|
|
Packit |
5e46da |
* the method's name.
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* the method's descriptor (see {@link Type Type}).
|
|
Packit |
5e46da |
* @param itf
|
|
Packit |
5e46da |
* if the method's owner class is an interface.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitMethodInsn(int opcode, String owner, String name,
|
|
Packit |
5e46da |
String desc, boolean itf) {
|
|
Packit |
5e46da |
if (api < Opcodes.ASM5) {
|
|
Packit |
5e46da |
if (itf != (opcode == Opcodes.INVOKEINTERFACE)) {
|
|
Packit |
5e46da |
throw new IllegalArgumentException(
|
|
Packit |
5e46da |
"INVOKESPECIAL/STATIC on interfaces require ASM 5");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
visitMethodInsn(opcode, owner, name, desc);
|
|
Packit |
5e46da |
return;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitMethodInsn(opcode, owner, name, desc, itf);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits an invokedynamic instruction.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param name
|
|
Packit |
5e46da |
* the method's name.
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* the method's descriptor (see {@link Type Type}).
|
|
Packit |
5e46da |
* @param bsm
|
|
Packit |
5e46da |
* the bootstrap method.
|
|
Packit |
5e46da |
* @param bsmArgs
|
|
Packit |
5e46da |
* the bootstrap method constant arguments. Each argument must be
|
|
Packit |
5e46da |
* an {@link Integer}, {@link Float}, {@link Long},
|
|
Packit |
5e46da |
* {@link Double}, {@link String}, {@link Type} or {@link Handle}
|
|
Packit |
5e46da |
* value. This method is allowed to modify the content of the
|
|
Packit |
5e46da |
* array so a caller should expect that this array may change.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
|
|
Packit |
5e46da |
Object... bsmArgs) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a jump instruction. A jump instruction is an instruction that may
|
|
Packit |
5e46da |
* jump to another instruction.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param opcode
|
|
Packit |
5e46da |
* the opcode of the type instruction to be visited. This opcode
|
|
Packit |
5e46da |
* is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ,
|
|
Packit |
5e46da |
* IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE,
|
|
Packit |
5e46da |
* IF_ACMPEQ, IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL.
|
|
Packit |
5e46da |
* @param label
|
|
Packit |
5e46da |
* the operand of the instruction to be visited. This operand is
|
|
Packit |
5e46da |
* a label that designates the instruction to which the jump
|
|
Packit |
5e46da |
* instruction may jump.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitJumpInsn(int opcode, Label label) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitJumpInsn(opcode, label);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a label. A label designates the instruction that will be visited
|
|
Packit |
5e46da |
* just after it.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param label
|
|
Packit |
5e46da |
* a {@link Label Label} object.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitLabel(Label label) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitLabel(label);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
// -------------------------------------------------------------------------
|
|
Packit |
5e46da |
// Special instructions
|
|
Packit |
5e46da |
// -------------------------------------------------------------------------
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a LDC instruction. Note that new constant types may be added in
|
|
Packit |
5e46da |
* future versions of the Java Virtual Machine. To easily detect new
|
|
Packit |
5e46da |
* constant types, implementations of this method should check for
|
|
Packit |
5e46da |
* unexpected constant types, like this:
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* if (cst instanceof Integer) {
|
|
Packit |
5e46da |
* // ...
|
|
Packit |
5e46da |
* } else if (cst instanceof Float) {
|
|
Packit |
5e46da |
* // ...
|
|
Packit |
5e46da |
* } else if (cst instanceof Long) {
|
|
Packit |
5e46da |
* // ...
|
|
Packit |
5e46da |
* } else if (cst instanceof Double) {
|
|
Packit |
5e46da |
* // ...
|
|
Packit |
5e46da |
* } else if (cst instanceof String) {
|
|
Packit |
5e46da |
* // ...
|
|
Packit |
5e46da |
* } else if (cst instanceof Type) {
|
|
Packit |
5e46da |
* int sort = ((Type) cst).getSort();
|
|
Packit |
5e46da |
* if (sort == Type.OBJECT) {
|
|
Packit |
5e46da |
* // ...
|
|
Packit |
5e46da |
* } else if (sort == Type.ARRAY) {
|
|
Packit |
5e46da |
* // ...
|
|
Packit |
5e46da |
* } else if (sort == Type.METHOD) {
|
|
Packit |
5e46da |
* // ...
|
|
Packit |
5e46da |
* } else {
|
|
Packit |
5e46da |
* // throw an exception
|
|
Packit |
5e46da |
* }
|
|
Packit |
5e46da |
* } else if (cst instanceof Handle) {
|
|
Packit |
5e46da |
* // ...
|
|
Packit |
5e46da |
* } else {
|
|
Packit |
5e46da |
* // throw an exception
|
|
Packit |
5e46da |
* }
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param cst
|
|
Packit |
5e46da |
* the constant to be loaded on the stack. This parameter must be
|
|
Packit |
5e46da |
* a non null {@link Integer}, a {@link Float}, a {@link Long}, a
|
|
Packit |
5e46da |
* {@link Double}, a {@link String}, a {@link Type} of OBJECT or
|
|
Packit |
5e46da |
* ARRAY sort for <tt>.class</tt> constants, for classes whose
|
|
Packit |
5e46da |
* version is 49.0, a {@link Type} of METHOD sort or a
|
|
Packit |
5e46da |
* {@link Handle} for MethodType and MethodHandle constants, for
|
|
Packit |
5e46da |
* classes whose version is 51.0.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitLdcInsn(Object cst) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitLdcInsn(cst);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits an IINC instruction.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param var
|
|
Packit |
5e46da |
* index of the local variable to be incremented.
|
|
Packit |
5e46da |
* @param increment
|
|
Packit |
5e46da |
* amount to increment the local variable by.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitIincInsn(int var, int increment) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitIincInsn(var, increment);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a TABLESWITCH instruction.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param min
|
|
Packit |
5e46da |
* the minimum key value.
|
|
Packit |
5e46da |
* @param max
|
|
Packit |
5e46da |
* the maximum key value.
|
|
Packit |
5e46da |
* @param dflt
|
|
Packit |
5e46da |
* beginning of the default handler block.
|
|
Packit |
5e46da |
* @param labels
|
|
Packit |
5e46da |
* beginnings of the handler blocks. <tt>labels[i]</tt> is the
|
|
Packit |
5e46da |
* beginning of the handler block for the <tt>min + i</tt> key.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitTableSwitchInsn(int min, int max, Label dflt,
|
|
Packit |
5e46da |
Label... labels) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitTableSwitchInsn(min, max, dflt, labels);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a LOOKUPSWITCH instruction.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param dflt
|
|
Packit |
5e46da |
* beginning of the default handler block.
|
|
Packit |
5e46da |
* @param keys
|
|
Packit |
5e46da |
* the values of the keys.
|
|
Packit |
5e46da |
* @param labels
|
|
Packit |
5e46da |
* beginnings of the handler blocks. <tt>labels[i]</tt> is the
|
|
Packit |
5e46da |
* beginning of the handler block for the <tt>keys[i]</tt> key.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitLookupSwitchInsn(dflt, keys, labels);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a MULTIANEWARRAY instruction.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* an array type descriptor (see {@link Type Type}).
|
|
Packit |
5e46da |
* @param dims
|
|
Packit |
5e46da |
* number of dimensions of the array to allocate.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitMultiANewArrayInsn(String desc, int dims) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitMultiANewArrayInsn(desc, dims);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits an annotation on an instruction. This method must be called just
|
|
Packit |
5e46da |
* after the annotated instruction. It can be called several times
|
|
Packit |
5e46da |
* for the same instruction.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param typeRef
|
|
Packit |
5e46da |
* a reference to the annotated type. The sort of this type
|
|
Packit |
5e46da |
* reference must be {@link TypeReference#INSTANCEOF INSTANCEOF},
|
|
Packit |
5e46da |
* {@link TypeReference#NEW NEW},
|
|
Packit |
5e46da |
* {@link TypeReference#CONSTRUCTOR_REFERENCE
|
|
Packit |
5e46da |
* CONSTRUCTOR_REFERENCE}, {@link TypeReference#METHOD_REFERENCE
|
|
Packit |
5e46da |
* METHOD_REFERENCE}, {@link TypeReference#CAST CAST},
|
|
Packit |
5e46da |
* {@link TypeReference#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
|
|
Packit |
5e46da |
* CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
|
|
Packit |
5e46da |
* {@link TypeReference#METHOD_INVOCATION_TYPE_ARGUMENT
|
|
Packit |
5e46da |
* METHOD_INVOCATION_TYPE_ARGUMENT},
|
|
Packit |
5e46da |
* {@link TypeReference#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
|
|
Packit |
5e46da |
* CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
|
|
Packit |
5e46da |
* {@link TypeReference#METHOD_REFERENCE_TYPE_ARGUMENT
|
|
Packit |
5e46da |
* METHOD_REFERENCE_TYPE_ARGUMENT}. See {@link TypeReference}.
|
|
Packit |
5e46da |
* @param typePath
|
|
Packit |
5e46da |
* the path to the annotated type argument, wildcard bound, array
|
|
Packit |
5e46da |
* element type, or static inner type within 'typeRef'. May be
|
|
Packit |
5e46da |
* <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* the class descriptor of the annotation class.
|
|
Packit |
5e46da |
* @param visible
|
|
Packit |
5e46da |
* <tt>true</tt> if the annotation is visible at runtime.
|
|
Packit |
5e46da |
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
|
Packit |
5e46da |
* this visitor is not interested in visiting this annotation.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public AnnotationVisitor visitInsnAnnotation(int typeRef,
|
|
Packit |
5e46da |
TypePath typePath, String desc, boolean visible) {
|
|
Packit |
5e46da |
if (api < Opcodes.ASM5) {
|
|
Packit |
5e46da |
throw new RuntimeException();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
return mv.visitInsnAnnotation(typeRef, typePath, desc, visible);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return null;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
// -------------------------------------------------------------------------
|
|
Packit |
5e46da |
// Exceptions table entries, debug information, max stack and max locals
|
|
Packit |
5e46da |
// -------------------------------------------------------------------------
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a try catch block.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param start
|
|
Packit |
5e46da |
* beginning of the exception handler's scope (inclusive).
|
|
Packit |
5e46da |
* @param end
|
|
Packit |
5e46da |
* end of the exception handler's scope (exclusive).
|
|
Packit |
5e46da |
* @param handler
|
|
Packit |
5e46da |
* beginning of the exception handler's code.
|
|
Packit |
5e46da |
* @param type
|
|
Packit |
5e46da |
* internal name of the type of exceptions handled by the
|
|
Packit |
5e46da |
* handler, or <tt>null</tt> to catch any exceptions (for
|
|
Packit |
5e46da |
* "finally" blocks).
|
|
Packit |
5e46da |
* @throws IllegalArgumentException
|
|
Packit |
5e46da |
* if one of the labels has already been visited by this visitor
|
|
Packit |
5e46da |
* (by the {@link #visitLabel visitLabel} method).
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitTryCatchBlock(Label start, Label end, Label handler,
|
|
Packit |
5e46da |
String type) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitTryCatchBlock(start, end, handler, type);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits an annotation on an exception handler type. This method must be
|
|
Packit |
5e46da |
* called after the {@link #visitTryCatchBlock} for the annotated
|
|
Packit |
5e46da |
* exception handler. It can be called several times for the same exception
|
|
Packit |
5e46da |
* handler.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param typeRef
|
|
Packit |
5e46da |
* a reference to the annotated type. The sort of this type
|
|
Packit |
5e46da |
* reference must be {@link TypeReference#EXCEPTION_PARAMETER
|
|
Packit |
5e46da |
* EXCEPTION_PARAMETER}. See {@link TypeReference}.
|
|
Packit |
5e46da |
* @param typePath
|
|
Packit |
5e46da |
* the path to the annotated type argument, wildcard bound, array
|
|
Packit |
5e46da |
* element type, or static inner type within 'typeRef'. May be
|
|
Packit |
5e46da |
* <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* the class descriptor of the annotation class.
|
|
Packit |
5e46da |
* @param visible
|
|
Packit |
5e46da |
* <tt>true</tt> if the annotation is visible at runtime.
|
|
Packit |
5e46da |
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
|
Packit |
5e46da |
* this visitor is not interested in visiting this annotation.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public AnnotationVisitor visitTryCatchAnnotation(int typeRef,
|
|
Packit |
5e46da |
TypePath typePath, String desc, boolean visible) {
|
|
Packit |
5e46da |
if (api < Opcodes.ASM5) {
|
|
Packit |
5e46da |
throw new RuntimeException();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
return mv.visitTryCatchAnnotation(typeRef, typePath, desc, visible);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return null;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a local variable declaration.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param name
|
|
Packit |
5e46da |
* the name of a local variable.
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* the type descriptor of this local variable.
|
|
Packit |
5e46da |
* @param signature
|
|
Packit |
5e46da |
* the type signature of this local variable. May be
|
|
Packit |
5e46da |
* <tt>null</tt> if the local variable type does not use generic
|
|
Packit |
5e46da |
* types.
|
|
Packit |
5e46da |
* @param start
|
|
Packit |
5e46da |
* the first instruction corresponding to the scope of this local
|
|
Packit |
5e46da |
* variable (inclusive).
|
|
Packit |
5e46da |
* @param end
|
|
Packit |
5e46da |
* the last instruction corresponding to the scope of this local
|
|
Packit |
5e46da |
* variable (exclusive).
|
|
Packit |
5e46da |
* @param index
|
|
Packit |
5e46da |
* the local variable's index.
|
|
Packit |
5e46da |
* @throws IllegalArgumentException
|
|
Packit |
5e46da |
* if one of the labels has not already been visited by this
|
|
Packit |
5e46da |
* visitor (by the {@link #visitLabel visitLabel} method).
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitLocalVariable(String name, String desc, String signature,
|
|
Packit |
5e46da |
Label start, Label end, int index) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitLocalVariable(name, desc, signature, start, end, index);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits an annotation on a local variable type.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param typeRef
|
|
Packit |
5e46da |
* a reference to the annotated type. The sort of this type
|
|
Packit |
5e46da |
* reference must be {@link TypeReference#LOCAL_VARIABLE
|
|
Packit |
5e46da |
* LOCAL_VARIABLE} or {@link TypeReference#RESOURCE_VARIABLE
|
|
Packit |
5e46da |
* RESOURCE_VARIABLE}. See {@link TypeReference}.
|
|
Packit |
5e46da |
* @param typePath
|
|
Packit |
5e46da |
* the path to the annotated type argument, wildcard bound, array
|
|
Packit |
5e46da |
* element type, or static inner type within 'typeRef'. May be
|
|
Packit |
5e46da |
* <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
|
Packit |
5e46da |
* @param start
|
|
Packit |
5e46da |
* the fist instructions corresponding to the continuous ranges
|
|
Packit |
5e46da |
* that make the scope of this local variable (inclusive).
|
|
Packit |
5e46da |
* @param end
|
|
Packit |
5e46da |
* the last instructions corresponding to the continuous ranges
|
|
Packit |
5e46da |
* that make the scope of this local variable (exclusive). This
|
|
Packit |
5e46da |
* array must have the same size as the 'start' array.
|
|
Packit |
5e46da |
* @param index
|
|
Packit |
5e46da |
* the local variable's index in each range. This array must have
|
|
Packit |
5e46da |
* the same size as the 'start' array.
|
|
Packit |
5e46da |
* @param desc
|
|
Packit |
5e46da |
* the class descriptor of the annotation class.
|
|
Packit |
5e46da |
* @param visible
|
|
Packit |
5e46da |
* <tt>true</tt> if the annotation is visible at runtime.
|
|
Packit |
5e46da |
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
|
Packit |
5e46da |
* this visitor is not interested in visiting this annotation.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
|
|
Packit |
5e46da |
TypePath typePath, Label[] start, Label[] end, int[] index,
|
|
Packit |
5e46da |
String desc, boolean visible) {
|
|
Packit |
5e46da |
if (api < Opcodes.ASM5) {
|
|
Packit |
5e46da |
throw new RuntimeException();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
return mv.visitLocalVariableAnnotation(typeRef, typePath, start,
|
|
Packit |
5e46da |
end, index, desc, visible);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return null;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits a line number declaration.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param line
|
|
Packit |
5e46da |
* a line number. This number refers to the source file from
|
|
Packit |
5e46da |
* which the class was compiled.
|
|
Packit |
5e46da |
* @param start
|
|
Packit |
5e46da |
* the first instruction corresponding to this line number.
|
|
Packit |
5e46da |
* @throws IllegalArgumentException
|
|
Packit |
5e46da |
* if <tt>start</tt> has not already been visited by this
|
|
Packit |
5e46da |
* visitor (by the {@link #visitLabel visitLabel} method).
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitLineNumber(int line, Label start) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitLineNumber(line, start);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits the maximum stack size and the maximum number of local variables
|
|
Packit |
5e46da |
* of the method.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* @param maxStack
|
|
Packit |
5e46da |
* maximum stack size of the method.
|
|
Packit |
5e46da |
* @param maxLocals
|
|
Packit |
5e46da |
* maximum number of local variables for the method.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitMaxs(int maxStack, int maxLocals) {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitMaxs(maxStack, maxLocals);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/**
|
|
Packit |
5e46da |
* Visits the end of the method. This method, which is the last one to be
|
|
Packit |
5e46da |
* called, is used to inform the visitor that all the annotations and
|
|
Packit |
5e46da |
* attributes of the method have been visited.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
public void visitEnd() {
|
|
Packit |
5e46da |
if (mv != null) {
|
|
Packit |
5e46da |
mv.visitEnd();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|