Re: [ANN] jfli - a Java FLI for LispWorks

From: Andras Simon (andras_at_hexagon.renyi.hu)
Date: 07/12/04


Date: 12 Jul 2004 20:35:14 +0200

Rich Hickey <jfliNOO@SPPAMMrichhickey.com> writes:

> A beta of jfli, an open-source Java Foreign Language Interface for
> LispWorks, is now available:
>
> http://jfli.sourceforge.net

This is very, very cool stuff!

Just two comments for now.

1. I have applied all the advice given on the LW mailing list, but still, at the
point where jni-create-java-vm is called, LW dies with segmentation violation.

Has anyone been able to run it on Linux?

2. How do you plan to go about subclassing Java classes? My experience is that
in using Java libraries, the ability to create instances of Java classes and
call Java methods is not enough. Maybe there is a way around this (other than
writing those subclasses in Java) that I'm not aware of.

I struggled with this problem in ABCL, and ended up writing a class generator,
which produces classes whose methods call Lisp functions. Here's an example
from http://wwww.math.bme.hu/~asimon/lisp/swt.cl (slightly modified):

(java:jnew-runtime-class
 "FileTreeLabelProvider" ;class name
 "org.eclipse.jface.viewers.LabelProvider" ;super
 '() ;no constructors
                                        ;methods
 `(("getText" "java.lang.String" ("java.lang.Object")
    ,#'(lambda (element this)
         (jcall-raw (jmethod "java.io.File" "getName") element))
    "public")
   ("getImage" "org.eclipse.swt.graphics.Image" ("java.lang.Object")
    ,#'(lambda (element this)
         (if (jcall (jmethod "java.io.File" "isDirectory") element)
             (java-instance (get-1 (get-image-registry) "folder"))
           (java-instance (get-1 (get-image-registry) "file"))))
    "public"))
 '() ;no fields
)
 
(For those who actually want to run this swt demo, all the necessary
ingredients are in http://wwww.math.bme.hu/~asimon/lisp/swt-example.tar.)

This has some weak points, the most prominent of which is that the Lisp
function gets Java objects as arguments, even though I can (and do) generate
clos wrappers for interesting Java classes (much as you do with
def-java-class). That's why I have to do (jcall (jmethod "java.io.File"
"isDirectory") element) instead of (is-directory-1 element) above.

But this is just an illustration of what kind of thing I'd like to see in
jfli.

Andras



Relevant Pages

  • Re: [ANN] jfli - a Java FLI for LispWorks
    ... How do you plan to go about subclassing Java classes? ... Well, a nice library, such as SWT/Eclipse, often offers interfaces. ...
    (comp.lang.lisp)
  • Re: pack it up
    ... >> I have written a few Java classes that I would like to run on another ... >> Best regards to all Java Pros ... >> Jochen Opp ... a DOS window but the JAVA command line window? ...
    (comp.lang.java.help)
  • Re: Importing java classes
    ... I need to call my own java class from within Matlab. ... where the last line is the directory of the VectorChooser class I copied ... way I can get matlab to read java classes is by starting matlab in the ...
    (comp.soft-sys.matlab)
  • Re: Load Java Class into Matlab
    ... > My Matlab is R14 SP1, installed on a WinXP Pro machine. ... > steps in the Matlab help menu, I still can not use my Java classes. ... > compiled class files are in directory C:\MyWork\Java\classes. ...
    (comp.soft-sys.matlab)