|
JNIPort for Dolphin Smalltalk |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
JNIPort |
Introduction(This page is just an introduction, the complete documentation for JNIPort is here.) JNIPort allows Java code to be invoked from Dolphin Smalltalk. It acts as a bridge between the world of Smalltalk objects and a JVM where Java code is executing. What's the point? Well, with JNIPort you can:
This version of JNIPort is known not to work with the recently released Dolphin 6. JNIPort is very roughly comparable to the facilities built into Dolphin for interacting with COM and Active-X objects. There are some big differences, though, mostly caused by the differences between the Java object model and COM. As with Dolphin's COM wrappers, 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 (as by the Dolphin Active-X Wizard), or created dynamically. There are significant differences from the way that Dolphin wraps COM too. One is that Java has type-precise introspection (and no equivalent of VB!), so there's much less “guesswork” involved in generating wrapper methods. Another is that 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 DamperA few warnings before you start to expect too much:
DocumentationThe software is complex enough to need documentation. I suggest that you start by looking at the overview, which also includes a very simple example, and possibly this walkthrough of installing and configuring JNIPort. You might also like to look at some more complete examples. I cannot, in honesty, fail to recommend a look at the problems and limitations of JNIPort. The complete documentation is listed here. Packages
|
Copyright © Chris Uppal, 2003-2005
Java, JNI (probably), JVM (possibly), and God knows what else, are trademarks of Sun Microsystems, Inc.