Posted by bondolo
on September 13, 2007 at 2:54 PM PDT
JXSE (JXTA for Java SE/EE 5.0) 2.5 contains quite a number of exciting changes for JXTA application developers. This little series will look at a few of the important changes in the upcoming release.
JXSE 2.4 was the first version to require Java Standard Edition 5.0. For that release we used only a small amount of JSE 5 specific functionality. The requirement of JSE 5.0 was primarily about advancing the support matrix to include the then newly released JSE 6 and providing the opportunity to take advantage of new features in future releases. In JXSE 2.4.1 we started to make much greater use of JSE 5.0 specific features. The most obvious examples are the use of Java Generics
. In JXSE 2.5 we have continued to make greater use of both of these features and each are now used extensively through out the JXSE source. These two features have allowed us to greatly simplify and clarify the JXSE APIs and implementation.
The common case for Java generics involves being able to write type-safe algorithms which can be applied to any appropriate data-type. The most popular usage of generics is undoubtedly the Java SE Collection
utilities. In JXSE 2.5 we have converted virtually all of our usage of the collection classes to make use of the generified versions. For example, where a JXSE API previously returned Vector
it now likely that it will return Vector
. According to Java language rules programs which reference the "raw" Vector type will continue to work.
There are several advantages to the genericized API. The contents of the result Vector
are now explicit which makes the API clearer. This is the primary advantage. An obvious API is one which will be used correctly. Programs which use the API can also more easily avoid errors because they can be written with direct reference to the correct types. We've been able to find errors even within JXSE itself where the wrong type was being used. If you have been using older versions of JXSE we think you'll find using the updated versions of the APIs much more convenient and pleasing to use, especially if you use an IDE with code completion.
JXSE 2.5's use of enums is designed to be compile time compatible in all cases with previous versions of JXSE. Unfortunately, for internal language support reasons, programs which were compiled against 2.4.1 or earlier must be recompiled to use JXSE 2.5. The JXSE libraries have always tried to maintain version-to-version compile-time compatibility though, such as in the case of the conversion to use enum
, it has not always been possible to maintain runtime compatibility. The primary advantages of using enum
within JXSE has been to improve clarity and simply usage as well as to take advantage of enum properties such as the ability to use switch
statements for enum typed variables.