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

public class Descriptors {
    private static void toDesc(StringBuilder desc, Class<?> type) {
        if (type.isArray()) { // arrays
            int len = 1 + type.getName().lastIndexOf("[");
            for (int i = 0; i <= len; i++)
                desc.append('[');
            try {
                toDesc(desc, type.getComponentType());
            } catch (Exception e) {
                desc.append('L');
                String name = type.getName();
                desc.append(name.substring(0, name.length() - 2).replace(".", "/"));
                desc.append(';');
            }
        } else if (type.isPrimitive()) { // primitives
            desc.append(Primitives.getDesc(type));
        } else { // classes
            desc.append('L');
            desc.append(type.getName().replace('.', '/'));
            desc.append(';');
        }
    }

    public static String descMethod(Class<?> returnType, Class[] paramTypes) {
        StringBuilder desc = new StringBuilder();
        desc.append('(');
        if (paramTypes != null)
            for (final Class paramType : paramTypes)
                toDesc(desc, paramType);

        desc.append(')');
        if (returnType != null)
            toDesc(desc, returnType);

        return desc.toString();
    }

    public static String descField(Class<?> type) {
        StringBuilder builder = new StringBuilder();
        toDesc(builder, type);
        return builder.toString();
    }
}

@@ -49,34 +49,482 @@
 m;%0A%0A
-public class Descriptors %7B
+/**%0A * Utility %3Ccode%3Eclass%3C/code%3E to assist with building descriptors for methods and fields%0A * %0A * @author AgentTroll%0A * @version 1.0%0A */ %0Apublic class Descriptors %7B%0A    private Descriptors() %7B%7D%0A    %0A    /**%0A     * Builds a default descriptor appending a %3Ccode%3Eclass%3C/code%3E type to the %0A     * %7B@link java.lang.StringBuilder%7D%0A     * %0A     * @param desc the descriptor builder to append the type to%0A     * @param type the %3Ccode%3Eclass%3C/code%3E to append to the builder%0A     */ 
 %0A   
@@ -1348,32 +1348,309 @@
        %7D%0A    %7D%0A%0A
+    /**%0A     * Creates a descriptor for a method%0A     * %0A     * @param returnType the %3Ccode%3Ereturn class%3C/code%3E the method will exit with%0A     * @param paramTypes the parameters of the method%0A     * @return the method descriptor for the %3Ccode%3Ereturn%3C/code%3E and params%0A     */ %0A
     public stati
@@ -2047,24 +2047,271 @@
 g();%0A    %7D%0A%0A
+    /**%0A     * Shortcut method to build a field descriptor, creates a StringBuilder and returns the String%0A     * representation%0A     * %0A     * @param type the type the field represents%0A     * @return the descriptor for the declared type%0A     */ %0A
     public s

Update Descriptors.java