wiki:JavaFfi

Version 1 (modified by jpallister, 12 years ago) (diff)

Initial, very rough draft. But at least it exists...

Java Foreign Function Interface

(This is a very rough draft thrown together from an email by Alessio Stalla to the mailing list.)

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
jstatic
to access static fields and methods.
jfield
to access fields.
jproperty-value and (setf jproperty-value)
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.