15 Java interface
The LispWorks Java interface allows you to:
- Define "Java Callers" which are Lisp functions that call Java methods or constructors, or access Java fields. You can either define specific callers, or "import a Java class", which means automatically generating callers for all the class public methods, constructors and fields.
- Make and access Java arrays.
- Make calls from Java into Lisp, either by calling Lisp directly or making proxies that implement some Java interface ("Lisp proxy"), and using a Lisp proxy where Java requires an object that implements an interface.
- Access Java objects.
- Integrate Java in a limited way with CLOS.
- Make socket streams using Java sockets. See 25.9 Socket streams with Java sockets and SSL on Android.
Calling into Java using the callers and accessing arrays does not require any specific Java code. Calling from Java into Lisp requires having the com.lispworks.LispCalls class (supplied as a JAR file), and using methods from it.
The Java interface is a module which needs to be loaded by calling:
(require "java-interface")
The Java interface symbols are exported from the package LW-JI, documented in 39 The LW-JI Package.
The Java interface requires Java edition 6 or later.