Metagnostic
home

JNIPort for Dolphin Smalltalk

Goodies

JNIPort

Z-Kit

ListTree

Space Breakdown

F.M.B.

Ghoul

Miscellanea

Experiments

Changes

Prerequisites

Licence

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:

  • Supplement Smalltalk's libraries with the rather extensive Java libraries from Sun and other vendors.
  • Use the normal (to a Smalltalker) interactive way of playing with objects and code in workspaces to learn about and prototype Java operations.
  • Continue to use your legacy Java code as you migrate to a more grown-up language…

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 Damper

A few warnings before you start to expect too much:

  • JNIPort does not provide complete interoperability between Java and Smalltalk. For instance it is not possible to create Smalltalk subclasses of Java classes (or the other way around).
  • The facilities for calling back from Java into Smalltalk are weak, slow, and clunky.
  • JNIPort allows proper interaction with Java objects but it cannot magically give you the ability to redefine Java classes interactively too.
  • This is evolving software; I expect that some of the design will change, so you should assume that interfaces, etc, will change in future versions. Naturally, I think the interfaces are fairly stable, or I wouldn't be releasing it to public view, but I promise nothing.
  • I haven't yet thought much about how to deploy applications based on a mixture of Java and Smalltalk. It's clear that there would be problems – for instance the default Dolphin image stripper would remove needed wrapper classes. This is an area that needs further work.

Documentation

The 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

Package sizes and versions
Name Size Version
CU Java Quasi-UTF8 6715 1.00
CU JNI 386963 1.09
CU JNI Helper 15631 1.00
CU Java Base 657908 1.31
CU Java Base Tests 115959 1.03
CU Java Callbacks 67406 1.10
CU Java Callback Tests 44386 1.02
CU Java Wrapper Generation 113967 1.06
CU Java Ghost Classes 60579 1.10
CU Java Wrapper Generation Tests 63357 1.01
CU Java Additional Wrappers 180705 1.02
CU Java Status Monitor 131671 1.23
CU Java History Page 19345 1.06
CU Java Console Page 23107 1.02
CU Java Wrapper Wizard 69246 1.05
CU Java JRockit Patch 16905 1.00
CU Java Examples 8122 1.00
CU JNIPort 1525 1.00
CU JNIPort Tests 1352 1.00

Prerequisite packages' sizes and versions
Name Size Version
CU Abstract Collections 51193 4.02
CU Always 5976 3.01
CU Anonymous Subclass 2092 1.00
CU Binary Arrays 6126 2.00
CU Collection Adaptors 34195 1.02
CU Enhanced Scrolling Decorator 13841 1.02
CU Form Layout 27356 2.01
CU GDI Extensions 10083 0.0004 (unpublished)
CU Ghost Classes 7592 1.01
CU Graphics Base 135733 0.0150
CU Package-relative File Locator 11829 3.01
CU PluggableWeakSet 5238 0.0002 (unpublished)
CU PolyViewer 85322 1.03
CU PolyViewer Tools Base 20325 0.0009 (unpublished)
CU Rolling Accumulator 7243 2.00
CU Selection From List Presenter 70640 1.04
CU Sortblocks 16398 3.01
CU String Extensions 6885 1.00
CU Tools Base 34422 0.0009 (unpublished)
CU Varargs 22545 2.02
CU Windows Shell Extensions 4809 1.00

Copyright © Chris Uppal, 2003-2005

Java, JNI (probably), JVM (possibly), and God knows what else, are trademarks of Sun Microsystems, Inc.