[armedbear-devel] Proposed patch for ticket #58 (inspection of Java objects)

Alessio Stalla alessiostalla at gmail.com
Tue Jul 28 20:30:00 UTC 2009

I have added to our inspector the ability to look into Java classes,
showing the values of fields and allowing them to be further
Here's an example interaction:

CL-USER(1): (setq obj (jnew (jconstructor "java.util.ArrayList")))
#<JAVA-OBJECT java.util.ArrayList {98062F}>
CL-USER(2): (inspect obj)
#<JAVA-OBJECT java.util.ArrayList {98062F}> is an object of type JAVA-OBJECT.
The wrapped Java object is an instance of java.util.ArrayList:
   0 java-class -------> #<JAVA-OBJECT java.lang.Class {1FB7CBB}>
   1 fields -----------> (("serialVersionUID" 8683452581122892189 ...)
("elementData" # ...) ...)
[1i] CL-USER(3): :istep 1
A proper list with 4 elements at #x385715
   0-> ("serialVersionUID" 8683452581122892189 ...)
   1-> ("elementData" #(NIL NIL ...) ...)
   2-> ("size" 0 ...)
   3-> ("modCount" 0 ...)
[1i] CL-USER(4): :istep 1
A proper list with 3 elements at #xDD23CF
   0-> "elementData"
   1-> #(NIL NIL ...)
   2-> #<JAVA-OBJECT java.lang.reflect.Field {5A25F3}>
[1i] CL-USER(5):

As you can see, fields are triplets: the field name, the value, and
the Field metaobject. I chose to represent them as simple lists to
avoid having a class just for that purpose.

NB: since the field values are read when the object is first
inspected, and then translated to Lisp objects, the inspector will NOT
reflect the current state of the object should it be altered (e.g. by
another thread, or interactively by the user while inspecting). This
is important especially wrt. inner objects: if A contains B and later
C, inspecting A at a certain time will show me B, and inspecting B
will, unsurprisingly, show me B, not C - even if A contains C now. I
don't know if our inspector behaves like this for other objects too or
not, but I don't see any (easy) way to change this fact.

Next I'd like to show methods as well, and maybe even allow one to
easily call them interactively (e.g. by making a method be a shown as
triplet as well - the signature as a string, the
java.lang.reflect.Method metaobject, and a closure which, when
invoked, calls the method on the inspected object with the given

I'm also working on a graphical inspector, but that's a bit more in the works ;)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ticket58.patch
Type: text/x-patch
Size: 9601 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20090728/4ca18681/attachment.bin>

More information about the armedbear-devel mailing list