[armedbear-devel] Proposed patch for ticket #58 (inspection of Java objects)
russell_mcmanus at yahoo.com
Tue Jul 28 21:27:37 UTC 2009
I created some slime patches to improve inspector functionality for abcl.
I submitted that patch to the slime mailing list, but it was never applied.
I didn't have the inclination to push it any farther, but you might find the
code interesting / helpful.
----- Original Message ----
> From: Alessio Stalla <alessiostalla at gmail.com>
> To: armedbear-devel at common-lisp.net
> Sent: Tuesday, July 28, 2009 3:30:00 PM
> Subject: [armedbear-devel] Proposed patch for ticket #58 (inspection of Java objects)
> 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")))
> CL-USER(2): (inspect obj)
> #is an object of type JAVA-OBJECT.
> The wrapped Java object is an instance of java.util.ArrayList:
> 0 java-class -------> #
> 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-> #
> [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 ;)
More information about the armedbear-devel