From: Luke H. <ruk...@gm...> - 2006-08-22 23:55:50
|
Hi Alan, I filed away your little program in my memory bank for later use, as it seems the best FFI interface for abcl yet (my version was too cumbersome). I was wondering if you can post an updated version with any other docs? It's usable as-is, but any additions/extra documentation would be useful. It's great to use lisp as a scripting language to play with java classes, thank you for your contribution!! -Luke |
From: Alan R. <ala...@gm...> - 2006-08-23 02:47:54
|
The most current version is at http://svn.mumble.net:8080/svn/lsw/ trunk/jss/invoke.lisp There is some documentation at the top of the file, but it is incomplete, as you note. I will try to write some more, but in the interim, feel free to ask me questions. There's a bunch of code below http://svn.mumble.net:8080/svn/lsw/ trunk/ that uses it, if you are looking for examples. You'll need the jscheme and beanshell libs in http://svn.mumble.net: 8080/svn/lsw/trunk/lib/ Fairly recently there is some support for asdf, so you can write stuff like in http://svn.mumble.net:8080/svn/lsw/trunk/owl/owl.asd to easily add jars, or directories of jars to your asdf sysdefs. There's also some gc stuff: (java-gc), to force a gc (java-room) returning values allocated, total, and free memory (verbose-gc t/nil) to turn on or off java gc messages. I defined (get-java-field object field) , and (set-java-field object field value). Object is either a java object or a class name or symbol. Field is a string naming the field. There's (set-to-list set) and (list-to-list list), which convert java sets and lists, respectively, to lisp lists. http://svn.mumble.net:8080/svn/lsw/trunk/util/jss-condition.lisp makes the backtraces in slime more friendly when using it. In emacs I start abcl with this: (defun abcl() (interactive) (let ((inferior-lisp-program "~/repos/lsw/trunk/abcl")) (setq slime-connected-hook (cons (lambda(&rest args) (set-process-filter (slime-inferior-process) (lambda (process string) (slime-write-string string))) (pop slime-connected-hook)) slime-connected-hook)) (slime))) which causes output to system.out to be put in the repl (otherwise it is left in the inferior lisp window). Suggestions are welcome. Glad to hear it is of some use to you :) -Alan On Aug 22, 2006, at 7:55 PM, Luke Hope wrote: > Hi Alan, > > I filed away your little program in my memory bank for later use, as > it seems the best FFI interface for abcl yet (my version was too > cumbersome). > > I was wondering if you can post an updated version with any other > docs? It's usable as-is, but any additions/extra documentation would > be useful. > > It's great to use lisp as a scripting language to play with java > classes, thank you for your contribution!! > > -Luke |
From: Mark E. <mar...@gm...> - 2007-08-27 12:24:26
Attachments:
invoke.lisp.diff
|
Alan Ruttenberg wrote: > The most current version is at http://svn.mumble.net:8080/svn/lsw/ > trunk/jss/invoke.lisp Attached is a patch for JSS that somewhat simplifies the use of the ASDF :jar-file extension by using the ASDF ":components" inheritance mechanism. One now can simply write ; ASDF ... ((:module jars :pathname "" :components ((:jar-file "wsml2reasoner-datalog-iris-0_4"))) ; ... ASDF and have ABCL with JSS automatically add the file "wsml2reasoner-datalog-iris-0_4.jar" which resides in the same directory as the ASDF (*.asd) file to the JSS dynamic classpath. Previously, one had to eval the ASDF DEFSYSTEM form containing calls to MERGE-PATHNAMES to get the proper location of the jars registered. In the spirit of "if you use EVAL, something is probably broken...", this has always been an itch I wanted to scratch . . . As a convenience, this patch will normalize :jar-file entries ending in '.jar' to continue to work as they previously did. Note, that when specifying directories via ASDF :pathname components, one needs to include a trailing slash in the value: ; ASDF ... ((:module jars :pathname "lib/ext/iris/" components ((:jar-file "iris-0.3") (:jar-file "iris-parser-0.3"))) ; ...ASDF -- <Mar...@gm...> "[T]his is not a disentanglement from, but a progressive knotting into." |
From: Luke H. <ruk...@gm...> - 2006-08-23 05:04:28
|
Thanks for the prompt reply, Alan. I've been trying the cvs version and the 0.9 tar.gz versions of abcl I tried your new invoke and it fails to work on both: CL-USER(1): (load "invoke-new.lisp") Error loading /home/lhope/cvs/luke-lisp/lib/invoke-new.lisp at line 428 (offset 18952) Debugger invoked on condition of type UNDEFINED-FUNCTION: The function (SETF JARRAY-REF) is undefined. The old invoke works fine with 0.9, but for CVS, calls of the sort (#"method" <java object> <java non-primitive arg>) do a random java exception. I think its because the way you guess the signature doesn't work the same. I'm having some independent worries with slime-2.0 and abcl so I can't test invoke with it properly. abcl works okay, but it seems to be getting stuck in loops when printing out error messages or compiling. This is for both versions, under an uptodate amd64 6.06 ubuntu emacs21. -Luke |
From: Luke H. <ruk...@gm...> - 2006-08-23 05:25:38
|
I worked out that my problems were caused by a) Compiling abcl with an old copy floating around in the classpath. b) loading and not compile-loading invoke.lisp (I was doing this because of the problems with slime...) So disregard the last post except to note to avoid doing the above) On 8/23/06, Luke Hope <ruk...@gm...> wrote: > Thanks for the prompt reply, Alan. > > I've been trying the cvs version and the 0.9 tar.gz versions of abcl > > I tried your new invoke and it fails to work on both: > > CL-USER(1): (load "invoke-new.lisp") > Error loading /home/lhope/cvs/luke-lisp/lib/invoke-new.lisp at line > 428 (offset 18952) > Debugger invoked on condition of type UNDEFINED-FUNCTION: > The function (SETF JARRAY-REF) is undefined. > > The old invoke works fine with 0.9, but for CVS, calls of the sort > (#"method" <java object> <java non-primitive arg>) do a random java > exception. I think its because the way you guess the signature > doesn't work the same. > > I'm having some independent worries with slime-2.0 and abcl so I can't > test invoke with it properly. abcl works okay, but it seems to be > getting stuck in loops when printing out error messages or compiling. > This is for both versions, under an uptodate amd64 6.06 ubuntu > emacs21. > > -Luke > |