Skip to main content

All the Nasties

Posted by editor on January 16, 2006 at 8:31 AM PST

JRE code you shouldn't call

It's tempting to call code that you know is in the JRE, and that you also know is off-limits. The fact that the class is packaged as com.sun and not java or javax is enough to tell you that it's an implementation detail, not a public API. Yet it's a hard-to-resist practice at times. Until J2SE 1.4 brought the Image I/O API's to the core, Java graphics books often advocated using Sun's JPEG decoder and encoder classes, even though these were all but certain to be absent in non-Sun Java runtimes. When you need the functionality, and it's not available in a proper form, it's hard not to just go for it... hard until your stuff breaks in the field, of course.

David Herron writes about this in his blog about The non-public classes in Sun's Java implementation. Following up on a blog by Romain Guy about SwingUtilities2, David writes:

I'm sure the SwingUtilities2 class has some useful features. No doubt that's why it's there. But if one uses that class, one should absolutely expect their programs to break.

We treat the public documented API's as our contract with you, the developers of Java applications. We go to great length to maintain compatibility with the public API's. But when something is undocumented or otherwise clearly a private API, we feel very free to make changes.

The SwingUtilities2 class which Romain mentions is in the latter camp. We mave made zero contract with the public about that class, just like all the other private classes. Those are all implementation details which are free to change at any time as we refactor the internals to fix bugs and add features.

OK, everyone consider themselves warned? Great, let's move on...

Also in today's Weblogs is ,
Jacob Hookom writes about an Experiment: Going Stateless with JSF: "What if JSF components were stored in Request Scope instead of the session or client? What are the possible consequences versus the gains?"

Natural String Order, Stephen Kelvin writes:
"Make string comparisons a little more clever by correctly sorting contained numbers. Hey, Windows XP finally sorts files intelligently, e.g. picture 9.jpg < picture 10.jpg < picture 11.jpg. So your Java software should be able to avoid stupidities like picture 1.jpg < picture 10.jpg < picture 2.jpg"

In this week's Spotlight,
JXTA Community member Vanessa Williams writes: "while surfing around looking for research papers on JXTA, I came across a paper by Nicolas Theodoloz which contained in an appendix a reverse-engineered set of use cases for the J2SE reference implementation. With his permission, I have duplicated these in Wiki format and added them to the JXTA Wiki." This JXTA J2SE Reference Implementation Use Cases wiki page iterates through the steps required for working with discovery services (including publishing and getting advertisements, providing error notifications and becoming a peer), resolver services, pipe services, rendez-vous services, and more.

In Projects and

Kirill Grouchnikov has rounded up a set of useful GUI components, describing the process as A file viewer, a wizard and a button strip walk into a breadcrumb bar.... "During these two weeks I have refactored and extracted a collection of (more or less) useful components into one single Flamingo component suite right here at"

The NetBeans Community is getting closer, as NetBeans 5.0 has reached RC 1 status. The new version includes the Matisse GUI builder, better support for JSF and Struts, speedier code completion, better support for refactoring, version control, and debugging, and more. The final release of NetBeans 5.0 is scheduled for later this month.

In Also in
Java Today
, the SDN article Java Technology 2005: A Year in Review takes one last look at the year gone by, covering the growing adoption of J2SE 5.0 ("Tiger") and its prominent Generics feature, the availability of Java SE 6 ("Mustang") snapshot releases on, simplified Java naming and licensing, the creation of the GlassFish project, the rise of AJAX, and more.

Given a big enough project, it's easy for your exception-handling practices to fall into disarray, creating hazards for the well-being of your project. A few lazy empty-catch blocks here and there and you might never find what's going on. But properly declaring and propagating exceptions has proven unwieldy for many projects. In An Exception Handling Framework for J2EE Applications, ShriKant Vashishtha offers an alternative--a framework to wrap all exceptions in a base runtime exception, allowing you to drop your various "throws" declarations, and conveniently inspect and handle them in a single appropriate place.

Forum member mernst has a request regarding Mustang snapshots in today's Forums: Please put source into CVS.
"Hello J2SE meisters, you could make my life a lot easier, if you provided the JDK source bundle via CVS. Note I'm not talking about write access; I just want a convenient way to a) not download tens of megabytes every week b) easily merge updates with patches I'm preparing c) easily get the diff to submit my patch. Right now, everyone has to do the versioning himself. Thanks for considering."

Mobicents developers continue to track Google Talk integration opportunities. In
Re: Google Talk Voice opening up, rdeadman writes:
"I just noticed that Google has released a C++ reference implementation for Google Jingle. I'm one of the leads on GJTAPI, an open-source JTAPI and Jcc framework. I might be able to rustle up some interest in building a GJTAPI service provider for Jingle. One question is whether we just bridge through JNI to the Google libjingle library, or whether we build off the existing Java Google Talk APIs with native Java for talking the new protocol extensions."

In today's
News Headlines

Registered users can submit news items for the href=""> News Page using our
news submission
. All submissions go through an editorial review before being
posted to the site. You can also subscribe to the href=""> News RSS

Current and upcoming Java

Registered users can submit event listings for the href=""> Events Page using our href="">events submission form.
All submissions go through an editorial review before being posted to the

Archives and Subscriptions: This blog is delivered weekdays as
the Java
Today RSS feed
. Also, once this page is no longer featured as the
front page of it will be
archived along with other past issues in the href=""> Archive.

JRE code you shouldn't call