Printing Java Objects

We've extended the CLOS to be a bit more friendly to dealing with Java objects by allowing a JAVA:JCLASS specializer. This is especially useful for defining specializations of PRINT-OBJECT so that perhaps more useful information is returned when a JAVA-OBJECT is evaluated on the REPL.

For instance the following specialization would perhaps allow one to print more information about the contents of a java.util.Collection object

(defmethod print-object ((coll (java:jclass "java.util.Collection")) stream)

If you are adding the class you wish to specialize on, you need to specify the classloader. For example if using JSS, you will need to do something like

(defmethod print-object ((device-id (java:jclass "" 
                                    (#"getBaseLoader" cl-user::*classpath-manager*)))
Last modified 7 years ago Last modified on 04/04/11 13:32:54