[armedbear-devel] Using Java Libraries

Alessio Stalla alessiostalla at gmail.com
Mon Oct 19 12:41:57 UTC 2009


On Mon, Oct 19, 2009 at 1:48 PM, nitralime <nitralime at 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/lisp/Java.java).
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




More information about the armedbear-devel mailing list