On Mon, Oct 19, 2009 at 1:48 PM, nitralime nitralime@googlemail.com wrote:
Hi folks,
I'm searching for a (more systematic) documentation (or tutorial) about how to use Java libraries from ABCL.
I couldn't find anything else except the examples on "http://trac.common-lisp.net/armedbear/browser/trunk/abcl/examples/abcl".
Is there any such tutorial (or documentation) at all?
I'm not aware of any tutorial, however if you know the Java reflection API you'll find that abcl's operators maps quite well to it. A quick "cheat sheet":
(jclass <class name>) gives you a Java class (jmethod <java class> <method names> <&rest argument types>) gives you a method (jconstructor <java class> <&rest argument types>) a constructor
(jnew <constructor> <&rest arguments>) instantiates a new Java object (jcall <method> <object> <&rest arguments>) calls a method
then there's jstatic to access static fields and methods, and iirc jfield to access fields. Oh, and jproperty-value and (setf jproperty-value) to access "properties" following the Java Bean convention (setXXX and getXXX). That's almost all; there is some more advanced stuff (e.g. manipulating Java arrays).
You can find most or all of this stuff inside Java.java (http://trac.common-lisp.net/armedbear/browser/trunk/abcl/src/org/armedbear/l...). It's not documented but quite readable.
Also, there's an "invoke.lisp" somewhere on the net which simplifies the Java API (at the cost of some more runtime reflection). IIRC it depends on a non-abcl Java class. I also wrote my own ad-hoc NIH-syndrome-influenced Java simplification layer which is less powerful but does not depend on external stuff.
hth, Alessio