From: Alan R. <ala...@gm...> - 2010-01-14 14:44:32
|
Also, I get: (defmethod print-object ((obj (jclass "java.net.URI")) stream) (print-unreadable-object (obj stream :identity t :type t))) -> ; Evaluation aborted. -Alan 2010/1/14 Alan Ruttenberg <ala...@gm...>: > Where's this implemented? It doesn't work for me because jclass doesn't find classes on the dynamically extended classpath I use. > > Would this method be called when a backtrace used in slime is constructed? > > Thanks, > Alan > > On Thu, Jan 14, 2010 at 9:38 AM, Alessio Stalla <ale...@gm...> wrote: >> On Thu, Jan 14, 2010 at 3:33 PM, Alan Ruttenberg >> <ala...@gm...> wrote: >>> The Jena toolkit has antisocially defined the toString method of an >>> important object to be computationally expensive - it triggers a >>> description logical classification process in some cases, something >>> which can blow out memory or take a very very long time. >>> >>> Therefore I need to be able to override that behavior so that if I >>> happen to get a stack trace or other wise cause one to be printed >>> toString is not called. >>> >>> As far as I can tell, it seems that the case of printing a java object >>> is handled by >>> >>> public String writeToString() in JavaObject.java >>> >>> An approach that makes sense to me would be to have this method look >>> for an eql method with the class of the object as specializer. >>> >>> (defmethod java-object-to-string ((class (eql (load-time-value >>> (find-java-class "com.hp.hpl.jena.ontology.impl.OntModelImpl")))))) >>> ..) >>> >>> and if such a method exists, call it instead of using the default >>> implementation. >>> >>> Other ideas welcome. >> >> I believe >> >> (defmethod print-object ((obj (jclass "com.foo.whatever")) stream) ...) >> >> should do, at least when the printing is done in Lisp through the >> standard CL printing functions. >> >> hth, >> Ale >> > > |