JNIPort is a Smalltalk library which allows Java code to be invoked from Smalltalk. It acts as a bridge between the world of Smalltalk objects and a Java Virtual Machine (JVM) where Java code is executing. With JNIPort you can:
You talk to a Java object via a Smalltalk object that acts as a proxy for it. You can call Java methods via the proxy using a lowish-level API where you have to tell the proxy what the method name is, what the argument types are, and so on. Alternatively you can use a higher level of wrapper methods that are either statically generated, or created dynamically.
Java classes are represented explicitly by wrapper objects (called class statics), so each proxy for a Java instance has both a Smalltalk class and a reference to the (shared) class static. The Smalltalk class defines the wrapper methods for calling the Java object's methods, and accessing its fields. The class static is the single member of a different Smalltalk class that has methods for using the “static” methods and fields of the Java class. The class static also has methods corresponding to the Java class's constructors, so it acts as a factory for new instances. (That means that from the point of view of a JNIPort programmer, Java classes really are objects!)
A few warnings before you start to expect too much:
JNIPort was originally written by Chris Uppal for Dolphin Smalltalk and published under a liberal license which permits its use in commercial and non-commercial software.
Joachim Geidel has ported JNIPort to VisualWorks and Pharo.
JNIPort has been ported to VA Smalltalk by Ben van Dijk, Adriaan van Os and Rolf van der Vleuten. The VASt version is available from VAStGoodies.com.
If you would like to contribute to the documentation, including experience reports or tips and tricks, or if you would like to contribute to JNIPort itself or port it to other Smalltalk dialects, please send a note to Joachim Geidel.