[armedbear-cvs] r13278 - trunk/abcl/src/org/armedbear/lisp

mevenson at common-lisp.net mevenson at common-lisp.net
Sat Jun 4 20:25:07 UTC 2011


Author: mevenson
Date: Tue May 17 05:45:44 2011
New Revision: 13278

Log:
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.

Modified:
   trunk/abcl/src/org/armedbear/lisp/JavaObject.java

Modified: trunk/abcl/src/org/armedbear/lisp/JavaObject.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/JavaObject.java	Tue May 17 03:51:30 2011	(r13277)
+++ trunk/abcl/src/org/armedbear/lisp/JavaObject.java	Tue May 17 05:45:44 2011	(r13278)
@@ -401,6 +401,41 @@
             } else {
                 parts = Symbol.NCONC.execute(parts, getInspectedFields());
             }
+            if (obj instanceof java.lang.Class) {
+                Class o = (java.lang.Class)obj;
+                try {
+                    Class[] classes = o.getClasses();
+                    LispObject classesList = NIL;
+                    for (int i = 0; i < classes.length; i++) {
+                        classesList = classesList.push(JavaObject.getInstance(classes[i]));
+                    }
+                    if (!classesList.equals(NIL)) {
+                        parts = parts
+                            .push(new Cons("Member classes", classesList.nreverse()));
+                    }
+                } catch (SecurityException e) {
+                    Debug.trace(e);
+                }
+                Class[] interfaces = o.getInterfaces();
+                LispObject interfacesList = NIL;
+                for (int i = 0; i < interfaces.length; i++) {
+                    interfacesList = interfacesList.push(JavaObject.getInstance(interfaces[i]));
+                }
+                if (!interfacesList.equals(NIL)) {
+                    parts = parts
+                        .push(new Cons("Interfaces", interfacesList.nreverse()));
+                }
+                LispObject superclassList = NIL;
+                Class superclass = o.getSuperclass();
+                while (superclass != null) {
+                    superclassList = superclassList.push(JavaObject.getInstance(superclass));
+                    superclass = superclass.getSuperclass();
+                }
+                if (!superclassList.equals(NIL)) {
+                    parts = parts
+                        .push(new Cons("Superclasses", superclassList.nreverse()));
+                }
+            }
             return parts.nreverse();
         } else {
             return NIL;




More information about the armedbear-cvs mailing list