FileDocCategorySizeDatePackage
MethodNode.javaAPI DocGlassfish v2 API6354Thu Mar 02 11:51:16 GMT 2006oracle.toplink.libraries.asm.tree

MethodNode

public class MethodNode extends Object
A node that represents a method.
author
Eric Bruneton

Fields Summary
public int
access
The method's access flags (see {@link oracle.toplink.libraries.asm.Constants}). This field also indicates if the method is synthetic and/or deprecated.
public String
name
The method's name.
public String
desc
The method's descriptor (see {@link oracle.toplink.libraries.asm.Type Type}).
public final List
exceptions
The internal names of the method's exception classes (see {@link oracle.toplink.libraries.asm.Type#getInternalName() getInternalName}). This list is a list of {@link String} objects.
public Attribute
attrs
The non standard attributes of the method.
public final List
instructions
The instructions of this method. This list is a list of {@link AbstractInsnNode AbstractInsnNode} and {@link Label Label} objects.
public final List
tryCatchBlocks
The try catch blocks of this method. This list is a list of {@link TryCatchBlockNode TryCatchBlockNode} objects.
public int
maxStack
The maximum stack size of this method.
public int
maxLocals
The maximum number of local variables of this method.
public final List
localVariables
The local variables of this method. This list is a list of {@link LocalVariableNode LocalVariableNode} objects.
public final List
lineNumbers
The line numbers of this method. This list is a list of {@link LineNumberNode LineNumberNode} objects.
public Attribute
codeAttrs
The non standard attributes of the method's code.
Constructors Summary
public MethodNode(int access, String name, String desc, String[] exceptions, Attribute attrs)
Constructs a new {@link MethodNode MethodNode} object.

param
access the method's access flags (see {@link oracle.toplink.libraries.asm.Constants}). This parameter also indicates if the method is synthetic and/or deprecated.
param
name the method's name.
param
desc the method's descriptor (see {@link oracle.toplink.libraries.asm.Type Type}).
param
exceptions the internal names of the method's exception classes (see {@link oracle.toplink.libraries.asm.Type#getInternalName() getInternalName}). May be null.
param
attrs the non standard attributes of the method.

    this.access = access;
    this.name = name;
    this.desc = desc;
    this.exceptions = new ArrayList();
    this.instructions = new ArrayList();
    this.tryCatchBlocks = new ArrayList();
    this.localVariables = new ArrayList();
    this.lineNumbers = new ArrayList();
    if (exceptions != null) {
      this.exceptions.addAll(Arrays.asList(exceptions));
    }
    this.attrs = attrs;
  
Methods Summary
public voidaccept(oracle.toplink.libraries.asm.ClassVisitor cv)
Makes the given class visitor visit this method.

param
cv a class visitor.

    String[] exceptions = new String[this.exceptions.size()];
    this.exceptions.toArray(exceptions);
    CodeVisitor mv = cv.visitMethod(access, name, desc, exceptions, attrs);
    if (mv != null && instructions.size() > 0) {
      int i;
      // visits instructions
      for (i = 0; i < instructions.size(); ++i) {
        Object insn = instructions.get(i);
        if (insn instanceof Label) {
          mv.visitLabel((Label)insn);
        } else {
          ((AbstractInsnNode)insn).accept(mv);
        }
      }
      // visits try catch blocks
      for (i = 0; i < tryCatchBlocks.size(); ++i) {
        ((TryCatchBlockNode)tryCatchBlocks.get(i)).accept(mv);
      }
      // visits maxs
      mv.visitMaxs(maxStack, maxLocals);
      // visits local variables
      for (i = 0; i < localVariables.size(); ++i) {
        ((LocalVariableNode)localVariables.get(i)).accept(mv);
      }
      // visits line numbers
      for (i = 0; i < lineNumbers.size(); ++i) {
        ((LineNumberNode)lineNumbers.get(i)).accept(mv);
      }
      // visits the code attributes
      Attribute attrs = codeAttrs;
      while (attrs != null) {
        mv.visitAttribute(attrs);
        attrs = attrs.next;
      }
    }