The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Java from Smalltalk

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Java from Smalltalk Posted: Feb 18, 2007 11:13 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Java from Smalltalk
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

As much as I dislike Java, it's indisputable that there are lots of available libraries, and using them from Smalltalk would be convenient. Well - Joachim Geidel has been working to make that possible from Cincom Smalltalk. I found this in the VWNC mailing list:

I have posted an updated version (0.29) of JNIPort for VisualWorks to the Cincom Public Repository.

JNIPort is an interface which makes it possible to transparently use Java libraries from Smalltalk. It invokes a Java VM using the Invocation Interface functions of the Java Native Interface (JNI). It can automatically generate wrapper classes for Java classes, enabling you to write code like this:



        | jvmSettings jvm zfClass zipfile entries |
        jvmSettings := (JVMSettings new)
                        name: 'JVM with ghost class generation';
                        yourself.
        jvmSettings usesGhosts: true.
        jvmSettings jniPortSettings useJNIHelperLibrary: true.
        jvm := JVM newWithSettings: jvmSettings.
        zfClass := jvm findClass: #'java.util.zip.ZipFile'.
        zipfile := zfClass new_String: 'MyZipFile.zip'.
        zipfile size_null. "--> answers an Integer"
        entries := zipfile entries_null.
        entries asAnEnumeration
                do: [:each | Transcript cr; print: each].

The methods new_String:, size_null, entries_null will be generated in a "ghost class" when the JVM accesses the Java class - no need to write code! (But be prepared to wait some seconds for ghost class generation during JVM creation.)

Most of the unit tests are green, but there are still some bugs:

  • There are some tests which fail because using out-of-range values for short and byte values does not raise exceptions as expected.
  • One test fails because of a bug somewhere in the conversion between Java and Smalltalk strings (only for two-byte characters).
  • When using a JVM with ghost class generation, accessing the result of methods answering single characters is broken (methods answer a Character, but try to use it as an Integer).
  • Callbacks from Java do not work yet, they raise an Exception because the Java side does not find the callback methods.
  • Using "lazy ghost classes" to avoid the long setup phase when starting a JVM using ghost classes does not work yet.

What's next (feel free to help me):

  • Fix the bug in String conversion.
  • Fix the bug of trying to interpret Character results as Integers for JNI methods answering jchars.
  • Add checks for out-of-bounds values for short and byte values.
  • Make callbacks work.
  • Add a GUI for configuration, monitoring, and inspecting ghost classes.
  • See what happens when using Java 1.6.

Joachim Geidel

This is a cool project, and it looks like we'll be including a snapshot of the code on the CD in "contributed".

Technorati Tags: ,

Read: Java from Smalltalk

Topic: The Open Door Previous Topic   Next Topic Topic: Insanity Defined

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use