The Bitterest Pill I Ever Had To Swallow
The compelling alternative to JNI
JNI isn't for the faint of heart, and not just because the very premise of using it implies being capable in both Java and C or one of its various offshoots (I propose we use the pattern
*C* to match C, C++, C#, and Objective-C). The last time I spent serious quality time with JNI, I felt like I was writing 20 lines of plumbing for every one line of native code I wrote, to say nothing of wrangling Ant to build the whole thing. It didn't help that calling into Objective-C basically required two header files for each implementation: one from
javah with my JNI headers, the other to declare the Obj-C interface. Unsurprisingly, I didn't get very far before I lost interest and patience
Duncan McGregor took on a similar task -- providing Java wrappers around calls to Mac OS X's Cocoa framework -- but he had the sense to opt-out of JNI. Instead, he used the JNA library to dynamically make native calls, without needing to muck around with JNI. As JNA's proect page describes it:
The JNA library uses a small native library stub to dynamically invoke native code. The developer uses a Java interface to describe functions and structures in the target native library. This makes it quite easy to take advantage of native platform features without incurring the high overhead of configuring and building JNI code for multiple platforms.
The result of Duncan's work is Rococoa, "a generic Java binding to the Mac Objective-C object system. It allows the creation and use of Objective-C objects in Java, and the implementation of Objective-C interfaces in Java." The project initially started as a QTKit wrapper to expose QuickTime functionality, Rococoa examples of which are provided on a QuickTime page.
All without fighting with JNI over parameter lists, accessing Java values from C, or any of that rigamarole. Nice.
Also in Java Today,
the OpenJDK 6 project, the backport of OpenJDK's sources to the JDK 6 spec, has put out a b06 source release. As described in Joe Darcy's blog, imaging classes have been moved from closed to open, JAX-WS 2.1 has been included, and the SNMP portion of the build has been modified to not fail when binary plugs are absent. Several other improvements are included. Another build is expected within two weeks.
The latest edition, issue 160, of the JavaTools Community Newsletter has been published, with a look ahead to JavaOne and the java.net Community Corner mini-talks, tool news from around the web, new projects in the community, a new graduation (loc-counter, and a Tool Tip on writing Scala applications with Eclipse.
In today's Weblogs, CayÂ Horstmann reports on James Gosling's recent tech talk, entitled
Feel of Java Revisited.
"On February 28, James Gosling gave a presentation in Sun's Santa Clara Campus auditorium (formerly a part of the Agnews Insane Asylum :-)), entitled "Feel of Java Revisited". The talk promised to revisit the classic Feel of Java paper that famously declared "Java is a blue collar language". I went with my graduate programming language class from SJSU, and here is what I learned."
DruÂ Devore makes a
Call for reasonable Java hosting.
"Java can compete against other languages, scripting or not, even for small sites, but it needs the support of the industry and the availability of reasonable hosting to do so."
Finally, RamaÂ Pulavarthi announces that
OpenJDK 6 now has JAX-WS 2.1 and JAXB 2.1. "OpenJDK 6 b06 is live now. The important update from b05 is that JAX-WS 2.1.1 with JAXB 2.1.6 is integrated in to OpenJDK 6 b06. So, All the JAX-WS 2.1 features and bug fixes that are in JDK 6 Update 4 Release are available in OpenJDK 6 b06."
This week's Spotlight is on
the Kijaro project, which "provides an area for those interested in adding new language features to Java to try out their ideas." Starting from a copy of the OpenJDK
javac compiler, the project has gone off on several interesting branches, including the First Class Methods implementation, properties, abstract enums, static implements/contracts, anonymous parameters, and list comprehensions. The project describes itself as "similar to KSL", but without the legal overhead.
In today's Forums,
wmeissner is interested in
Detecting which java2d operations are accelerated.
"How do I detect when a feature such as bi-linear interpolation can be accelerated by java2d This is for video rendering - when the opengl or direct3d pipelines are being used, I want the video component to be able to automagically figure out it can smooth the video scaling using bi-linear interpolation, but when using software rendering, just use nearest-neighbour."
agoubardreports a performance problem in JDKuN b12, in
Performance downgraded in applets.
"The reason I'm posting in this forum is because the problem found is related to graphics acceleration. When Java is refreshing the content of a window everything if fine but when Java is refreshing an applet included in the HTML then the CPU is quite intensively used even if you're just moving the mouse over it. Also when a JComboBox is displayed in a window, the menu is then display below the window."
kbr explains applet-sizing strategy in JDKuN, in
Re: Initially-hidden applet reports zero dimensions on startup using b12.
"In some circumstances (including having the applet tag hidden, but including dynamically generating the HTML of the applet tag) IE sends our ActiveX control several bogus width and height values. The logic attempting to deal with this was rewritten in the new Java Plug-In to simplify a huge bunch of hacks, and the new heuristics have been one problem area in the new plug-in. We'll try to figure out a way to be compatible with the old behavior."
Current and upcoming Java
- MarchÂ 4-7 - Java Posse Roundup 08
- MarchÂ 7-9 - Gateway Software Symposium 2008
- MarchÂ 10 - Java IDE day 2008 - Genova
- MarchÂ 12-14 - JSFDays 2008
- MarchÂ 14-16 - Twin Cities Software Symposium 2008
- MarchÂ 26-28 - TheServerSide Java Symposium
- AprilÂ 4-6 - New England Software Symposium 2008: Spring Edition
- AprilÂ 8-11 - JAX India 2008
- AprilÂ 11-13 - Bay Area Software Symposium 2008
- AprilÂ 18-20 - Great Lakes Software Symposium 2008: Spring Edition
Registered users can submit event listings for the
href="http://www.java.net/events">java.net Events Page using our
href="http://today.java.net/cs/user/create/e">events submission form.
All submissions go through an editorial review before being posted to the
Archives and Subscriptions: This blog is delivered weekdays as
Today RSS feed. Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.
The compelling alternative to JNI