Using Reflection

Many Java tools use Reflection.

Here's a bit from ClassDiagrammer.java.

Class
+ getModifiers() : int
+ getPackage() : Package
+ getName() : String
+ getSuperclass() : Class
+ getFields() : Field[]
+ getConstructors() : Constructor[]
+ getMethods() : Method[]
Field
+ getModifiers() : int
+ getName() : String
+ getType() : Class
Constructor
+ getModifiers() : int
+ getName() : String
+ getParameterTypes() : Class[]
+ getExceptionTypes() : Class[]
Method
+ getModifiers() : int
+ getName() : String
+ getParameterTypes() : Class[]
+ getExceptionTypes() : Class[]
+ getReturnType() : Class

java.lang.Class
java.lang.reflect.Constructor
java.lang.reflect.Field
java.lang.reflect.Method
private String[] getMethods(Class cl) {
    Method[] methods = cl.getDeclaredMethods();
    Vector methodStrs = new Vector();

    for (int i = 0; i < methods.length; i++) {
        String methodStr = "";

        int modifiers   = methods[i].getModifiers();
        String methName = methods[i].getName();
        Class[] parms   = methods[i].getParameterTypes();
        
        methodStr = getModifierSymbol(modifiers)
                  + methName
                  + getParamString(parms)
                  + getReturnString(methods[i]);
        methodStrs.add(methodStr);
    }

    return (String[]) methodStrs.toArray(new String[0]);
}

private String getParamString(Class[] parms) {
    String parmStr = "(";
    for (int i = 0; i < parms.length; i++) {
        if (i > 0) {
            parmStr += ", ";
        }

        parmStr += parms[i]getName();
    }
    parmStr += ")";
    return parmStr;
}