package com.gmail.woodyc40.commons.reflection.asm;

import com.gmail.woodyc40.commons.reflection.asm.sun.ClassFileAssembler;

public class BytecodeMethod {
    private final int    access;
    private final String name;
    private final String desc;

    private Pool.Attr attr;

    public BytecodeMethod(String methodName, int access, Class<?> ret, Class[] params) {
        this.access = access;
        this.name = methodName;
        this.desc = Descriptors.descMethod(ret, params);
    }

    public void addCode(Pool.CodeAttr attr) {
        this.attr = attr;
    }

    public void add(ClassBytecode bytecode) {
        ClassFileAssembler assembler = bytecode.getAssembler();
        Pool pool = bytecode.getConstantPool();

        assembler.emitShort((short) access); // Access
        assembler.emitShort((short) pool.newUTF(name)); // Name
        assembler.emitShort((short) pool.newUTF(desc)); // Descriptor
        assembler.emitShort((short) (attr != null ? 1 : 0)); // Attributes
        attr.toData(assembler);
    }
}

@@ -157,422 +157,1629 @@
     
-private final int    access;%0A    private final String name;%0A    private final String desc;%0A%0A    private Pool.Attr attr;%0A%0A    public BytecodeMethod(String methodName, int access, Class%3C?%3E ret, Class%5B%5D params) %7B%0A        this.access = access;%0A        this.name = methodName;%0A        this.desc = Descriptors.descMethod(ret, params);%0A    %7D%0A%0A    public void addCode(Pool.CodeAttr attr) %7B%0A        this.attr = attr;%0A    %7D%0A
+/**%0A     * Access flags for the method specified by %7B@link com.gmail.woodyc40.commons.reflection.asm.Modifiers%7D%0A     */ %0A    private final int    access;%0A    /**%0A     * The declared name of the method%0A     */ %0A    private final String name;%0A    /**%0A     * The method descriptor, for internal use only. Can be used to acquire method parameters and return type%0A     */ %0A    private final String desc;%0A%0A    /**%0A     * The code representing the call stack for this method%0A     */ %0A    private Pool.Attr attr;%0A%0A    /**%0A     * Builds a new instnace of the bytecode representation for a method%0A     * %0A     * @param methodName the declared name of the method%0A     * @param access the access flags for the method %0A     *        specified by %7B@link com.gmail.woodyc40.commons.reflection.asm.Modifiers%7D%0A     * @param ret the return type for the method, for example%0A     *        %3Ccode%3Epublic void foo() %7B%7D%3C/code%3E would be %3Ccode%3Evoid.class%3C/code%3E%0A     * @param params the parameters for the method, can be an empty array for no parameters%0A     */ %0A    public BytecodeMethod(String methodName, int access, Class%3C?%3E ret, Class%5B%5D params) %7B%0A        this.access = access;%0A        this.name = methodName;%0A        this.desc = Descriptors.descMethod(ret, params);%0A    %7D%0A%0A    /**%0A     * Associates a bytecode attribute for the method code%0A     * %0A     * @param attr the attribute to add representing the method call stack%0A     */ %0A    public void addCode(Pool.CodeAttr attr) %7B%0A        this.attr = attr;%0A    %7D%0A%0A    /**%0A     * Addes the method to a bytecode dump builder%0A     * %0A     * @param bytecode the builder to add the method to%0A     */ 
 %0A   
@@ -2198,16 +2198,46 @@
 ributes%0A
+        if (attr != null)%0A    
         

Update BytecodeMethod.java