Changeset 13278


Ignore:
Timestamp:
05/17/11 12:45:44 (10 years ago)
Author:
Mark Evenson
Message:

Add interfaces, superclasses and member classes for JAVA-OBJECT inspector.

Make the display of a java Class under SLIME (and via the built-in
inspector) a bit more useful by displaying a list of all superclasses
in "Superclasses", a list of all implemented interfaces in
"Interfaces", and a list of all member classes in "Member classes".

In general the information returned by the getParts() inspector
contract for java classes could be made quite a bit more useful by
adding the output of more methods such as getAnnotations() and
getCannonicalName() but for those not using the SLIME inspector there
may actually be too much information presented.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/JavaObject.java

    r13277 r13278  
    401401            } else {
    402402                parts = Symbol.NCONC.execute(parts, getInspectedFields());
     403            }
     404            if (obj instanceof java.lang.Class) {
     405                Class o = (java.lang.Class)obj;
     406                try {
     407                    Class[] classes = o.getClasses();
     408                    LispObject classesList = NIL;
     409                    for (int i = 0; i < classes.length; i++) {
     410                        classesList = classesList.push(JavaObject.getInstance(classes[i]));
     411                    }
     412                    if (!classesList.equals(NIL)) {
     413                        parts = parts
     414                            .push(new Cons("Member classes", classesList.nreverse()));
     415                    }
     416                } catch (SecurityException e) {
     417                    Debug.trace(e);
     418                }
     419                Class[] interfaces = o.getInterfaces();
     420                LispObject interfacesList = NIL;
     421                for (int i = 0; i < interfaces.length; i++) {
     422                    interfacesList = interfacesList.push(JavaObject.getInstance(interfaces[i]));
     423                }
     424                if (!interfacesList.equals(NIL)) {
     425                    parts = parts
     426                        .push(new Cons("Interfaces", interfacesList.nreverse()));
     427                }
     428                LispObject superclassList = NIL;
     429                Class superclass = o.getSuperclass();
     430                while (superclass != null) {
     431                    superclassList = superclassList.push(JavaObject.getInstance(superclass));
     432                    superclass = superclass.getSuperclass();
     433                }
     434                if (!superclassList.equals(NIL)) {
     435                    parts = parts
     436                        .push(new Cons("Superclasses", superclassList.nreverse()));
     437                }
    403438            }
    404439            return parts.nreverse();
Note: See TracChangeset for help on using the changeset viewer.