Sun delivers Kestrel, the newest version of Java 2

Exclusive article details Java 2 SDK v1.3 beta's new features, bug fixes, and incompatibilities

On the heels of a legal defeat in the Microsoft battle, Sun Microsystems delivers a beta release of its next-generation Java 2 Software Development Kit (SDK). Code-named Kestrel, the Java 2 SDK, version 1.3, is now available for early adopters to play with. The new version is not called Java 3, as some people suspected it might be -- at least not yet. For the moment, the fourth release of Java technology is called the Java 2 platform, version 1.3.

When examining the new release, do keep the bug-reporting URL handy (see Resources), as Joey Jarosz, president of hot-n-GUI Inc., an Internet design and consulting company, reports that it took his crew less than five minutes to find code that worked in the previous Java version but not in the 1.3 release. If you're eager to learn the details of the new release, the following provides a brief synopsis of what's new and different. As we'll see, you'll find plenty of new features, lots of bug fixes, changes to the existing toolset, and, unfortunately, some incompatibilities with previous Java versions.

New features

Version 1.3 of the Java 2 SDK introduces many improvements to the core Java 2 platform. Some of these changes improve Java's performance. (For example, there is roughly a 20 percent performance improvement in serialization/deserialization during RMI calls.) The vast majority of them, however, add additional capabilities to the core API set for the Java 2 platform.

Taking an API-level approach to the different changes, the following provides an overview of how the Java 2 platform has grown. Starting with the API documentation, the following new packages reveal several major additions:

  • java.awt.im.spi

    The Input Method Framework engine has been enhanced to provide a Service Provider Interface (SPI). (In fact, many of the new 1.3 packages include

    .spi

    subpackages for service providers.) The Input Method Framework SPI provides the ability to create alternative input mechanisms -- you can now suppport handwriting recognition on a Palm device, for instance. A tutorial is provided (see

    Resources

    ) that lets users enter city names by using three-character airport codes.

  • javax.media.sound.midi and javax.media.sound.sampled

    This is a derivative of the Headspace demonstration presented at JavaOne 1997 by company founder Thomas Dolby Robertson. That demonstration presented a software-based mixer and interactive sound capabilities within the Java runtime environment, and the possiblities revealed there have finally made it into the core libraries of the Java 2 SDK, version 1.3. With this version, developers now have easy access to a software-based audio mixer for manipulating digital sound and MIDI (musical instrument digital interface) devices. The core Java technology libraries no longer only support playing audio files; you can also capture sound, mix it, and play it back.

  • javax.rmi

    The Java 2 SDK, version 1.3 adds RMI-IIOP support to the Java 2 platform. Instead of having to choose between using RMI or CORBA/IIOP for distributed applications, your RMI-based applications can now use the IIOP protocol so that the applications can communicate with CORBA objects on the other end of the wire, permitting cross-language interoperability. Be aware that, although this is now possible, many headaches result (these are documented) due to the number of rules that your RMI program must obey. For example, your remote implementation classes must now inherit from

    javax.rmi.PortableRemoteObject

    (instead of

    UnicastRemoteObject

    ), and you cannot depend on or use any of the distributed garbage-collection facilities.

  • javax.naming

    Prior to the Java 2 SDK, version 1.3, the Java Naming and Directory Interface (JNDI) API was available as a standard extension to the Java 2 SDK, version 1.2 and JDK 1.1. Now, with the 1.3 release of the Java 2 platform, the JNDI capabilities are part of the core API set. What is JNDI? Basically, it is a lookup service: using JNDI, you ask to find things, like a printer or RMI service. JNDI service providers maintain a registry of locations where things are located and return objects upon request, assuming that they are found. The Java 2 SDK, version 1.3 includes three providers for Lightweight Directory Access Protocol (LDAP), CORBA Object Services (COS) Naming Service, and the Remote Method Invocation (RMI) Registry.

  • org.omg.* and javax.transaction

    Several enhancements have been made to the CORBA packages and the included ORB. Most of the updates were due to changes from the Object Management Group (OMG) for CORBA 2.3, such as support for the input and output of value types (as opposed to reference types).

In addition to full-fledged package additions, new classes have been added to existing packages, and new methods and constants to existing classes. We'll first look at the features focusing on the Abstract Windowing Toolkit (AWT). Then, we'll look at the enhancements outside of AWT.

  • The Font class provides dynamic font loading support through the new createFont() method. You'll no longer have trouble trying to make sure your users have specific fonts installed. For the time being, this method only supports TrueType fonts.
  • Printing has been enhanced through the new JobAttributes and PageAttributes classes, offering the ability to control paper size and orientation.
  • AWT and Java2D now support multiple monitors through the GraphicsConfiguration class.
  • The new java.awt.Robot class allows you to automate user interface testing by generating native UI events.
  • You can now get a list of registered listeners from a java.awt.Component with the new getListeners(Class listenerType) method.
  • AWT now supports native rendering of components, by placing the paint() method in a C/C++ native library.
  • Enhancements to the DataFlavor class provide better text transfer support for drag-and-drop and clipboard transfers.

Outside of AWT there are other enhancements:

  • The old java.lang.Math class has been moved to java.lang.StrictMath. There is a new Math class that permits answers to be different from old answers, under certain circumstances.
  • The Collections Framework has been enhanced to fill some obvious holes, adding the singletons List and Map, to go along with the singleton Set; an empty Map to go along with the empty List and Set; and a constructor for WeakHashMap that accepts a Map.
  • The Runtime class has a new method public void addShutdownHook(Thread hook) that provides a shutdown hook, for registering threads to run when the Java Virtual Machine begins its shutdown process.
  • Socket programming now supports the keep alive option as well as TCP half-close sockets for improved network communications usage.

The above simply highlights the many changes present in the Java 2 SDK, version 1.3. Unfortunately, the source code for the libraries isn't included with this beta release.

Fixing bugs

As is the case with most upgrades, you get your share of bug fixes in the 1.3 release of the Java 2 SDK. Sun's bug fix list (see Resources) includes 452 bugs that have been corrected. The area with the largest number of corrections is the JFC/Swing classes. Due to the significant number of changes as well as bug fixes to the JFC/Swing libraries, the JFC/Swing development team posted a description of the changes to The Swing Connection (see Resources).

Included with the bug fix list is a tally of votes from developers who are in the JDC Bug Parade. The bugs fixed with the leading number of votes follow:

  • 4101708: Add PNG image file format support to JDK (687 votes)
  • 4067405: PrintJob disregards the Properties (212 votes)
  • 4193603: Java performs illegal operation on Hydra (Windows Terminal Server) (135 votes)
  • 4186905: JTextPane no longer dispatches keyTyped events to a KeyListener (132 votes)
  • 4176136: JInternalFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE) is ignored (103 votes)

If you voted for one of these fixes, be sure you clear your vote and vote for another bug that you'd like to see Sun fix. There's still time to try to convince Sun to fix other problems with the 1.3 release. Unfortunately, for things like PNG (Portable Network Graphics -- an image format like GIF and JPEG) support, you need to look outside the core capabilities for support with the 1.2 release of the Java 2 platform (or go back further to the Java 1.1 runtime environment).

Tool changes

Besides all the library changes and added functionality, as described above, some of the underlying tools have changed. For example, the Java 2 Runtime Environment includes HotSpot technology and has been optimized for client-side performance, including reduced startup time. A quick test of the startup of a JFC/Project Swing example shows roughly a 25 to 50 percent startup improvement on a three-year-old Pentium Pro machine, a representative example of a typical machine used by a nondeveloper.

Other tool changes include a completely rewritten javac compiler, an IDL compiler (with the name changed from idltojava to idlj) now available with the SDK, and changes to the jar, rmic, jarsigner, and keytool programs.

Incompatibilities among releases

Sun has tried to keep incompatibilities among Java 2 releases to a minimum. So far there are no clarifications or amendments to the Java language specification. There are a mere five incompatibilities at the source-code level, only four of which will require a change in your source code. The one that doesn't require any changes is the hashCode() method of Double. It has been modified to return a value that reflects what the API calls for, to better utilize a HashMap or Hashtable. The remaining three may require source code changes:

  • The javax.swing.Timer class now conflicts with the new java.util.Timer class. If a source file imports from both packages with wildcards (import javax.swing.*; and import java.util.*;) and uses the JFC/Swing Timer class, a compilation error will result. It is necessary to add an import line to directly reference the original Timer class (import javax.swing.Timer;) if you want to keep your code working in the same manner as before.
  • Two security permissions have been added: java.sql.SQLPermission and javax.media.sound.sampled.AudioPermission. With SQLPermission, you need the new permission to change the log writer. If a program tried to change the log writer when running under a version 1.3 runtime environment, the program would fail until the new permission is added. For AudioPermission, previously no permission was necessary to listen to a user's microphone in order to purposely record or eavesdrop. Now you must have the permission in order for your program to work properly.
  • The last change involves the default visibility setting for JInternalFrame instances. In order to behave more like top-level windows and properly generate events when internal frames open properly, internal frames are now initially invisible. You'll need to add one line of source code to initially open/show the internal frame, either internalFrame.show() or internalFrame.setVisible(true).

Conclusion

As with all first beta versions of new "dot point" releases from Sun, the Java 2 SDK, Standard Edition, version 1.3, is definitely not for the deployment of production applications. In fact, the Binary Software Evaluation Agreement you must accept before downloading this version expressly forbids commercial use in clause 3.4 (and even forbids productive use). The SDK is a decent first cut for the public to get a sense of what's coming next. With Internet time pushing increasingly rapid software release cycles, keep in mind that you are trying out very early access beta software. Not everything that is to be added has been implemented yet. If you do evaluate the product, don't forget to let Sun know when you are done using it. According to clause 6.4 in the Binary Software Evaluation Agreement, you must provide written notification that you have completed your evaluation.

John Zukowski is a software mage with MageLang Institute, author of John Zukowski's Definitive Guide to Swing for Java 2 from Apress!, Mastering Java 2 from Sybex, and Java AWT Reference from O'Reilly & Associates, as well as the Focus on Java guide at the About.com. John is too busy to come up with a topic for his next book; what do you think it should be?

Learn more about this topic

Related: