Recently we had a discussion whether Biojava could use the novel features of Java1.5. Since I just have moved two larger applications (633 java files) to Java1.5 I would like to share my experiences with you.
Applying the new features to the source code took me two days: This was worth doing because I identified two bugs thanks to the Generics and Annotations of Java 1.5. 1. GENERICS: I added types to all collections E.g. public List getProteinsV() { ... } was turned into public List<Protein> getProteinsV() { ... } I found one bug where I added the wrong Object type! 2. ANNOTATIONS: I preceded all methods that override a method of the parent class with the annotation @Override. Indeed I found a hidden bug where I mistyped the name of a method ! Instead of of overriding a method I invented a new one which was not intended. This kind of bugs remains unnoticed in a Java1.4 environment. 3. Loops: I achieved a more compact source code by using foreach loops. The code is better readable now. In 1.4 the head of loops sometimes require 3 java lines which is now condensed to one single line. RETROWEAVER A sound argument against 1.5 was the broken compatibility to application servers still working with 1.4 and old Macintosh OSX. I used Retroweaver to convert the class files after compilation into 1.4 class format. As a result the program works on a 1.4 virtual machine as well as on a 1.5 machine. Fortunately, I did not find any problem related to the code conversion by Retroweaver. PERFORMANCE: The foreach loops are slightly slower. The autoboxing feature is dangerous in terms of performance because expensive object creation is hidden. For example the compiler would conveniently replace "10" by new Integer(10) for method parameters that require "Integer" and not "int". Therefore, I do not like autoboxing. I did not try but the alternative to StringBuffer is said to be faster because thread safty is omitted but still lacks standard String operations from other languages. DISADVANTAGES: 1. Jikes can not be used any more. Jikes compiles faster than javac and has a better error report. 2. The make script takes longer because Retroweaver must be run. 3. Some additional class files shipped with Retroweaver are required at runtime and makes the binary larger by 60kbytes. Well, that is not really significant. Conclusions: I would highly recommend migrating Biojava to 1.5. I hope this helps to make a decision. Christoph _______________________________________________ Biojava-l mailing list - Biojava-l@biojava.org http://biojava.org/mailman/listinfo/biojava-l