The Source for Java Technology Collaboration
User: Password:



Brian Maso

Brian Maso's Blog

Can't Go to the 1.5 Bleeding Edge? Bring it Back to 1.4!

Posted by jdcmember on May 19, 2005 at 05:05 PM | Comments (4)

Retroweaver 1.1 is a post-compile bytecode fixup tool. With it, Java 5 language features (enum types, varargs, auto-boxing, generics) will run on any 1.4 VM. Neat trick brought to you by Toby Reyelts.

Backport175 is a JSR 175 (Java Class and class member annotations) implementation for pre-1.5 VMs by Jonas Boner and Alexandre Vasseur. Out of the box, it supports using special JavaDoc tags and special post-compilation steps to embed Java 5 class and class member annotations in to compiled bytecode. Add to that a runtime annotation reader library that's forward and backward compatible with pre- and post-1.5, so the same reader code works in either enviroment. Another neat trick!

Putting the two together, you get something very cool. You compile normal Java 5 classes with annotations using a Java 5 compiler, then use Retroweaver to make the classes 1.4 compatible. Using the Backport175 implementation then to read the annotations (no special Backport175 post-compilation or special JavaDoc tags necessary).

The only trick is that after 1.5 compilation, you need to re-compile all you @interfaces as normal Java interfaces. (Extra work necessary if you depend on @interface default values.)

Using these two together, my next plan is to backport JAXB 2.0 to work on a 1.4 VM. Discussing the idea on the DevelopMentor ADVANCED-JAVA list, Vlad Roubstav in a very practical tone of voice said "...But if I were talking to an engineer at work trying to sell me on a solution architecture with 1.5 bytecode retrofitters in it, I would just laugh because no 2.0-1.0 delta can be worth deploying bytecode-manipulated draft RIs...". But I can't resist the temptation...

(Vlad, you have a homepage or blog?)


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • I've been using RetroWeaver with ScheduleWorld for around a year in production. I've never had a problem with it.

    Thank you Toby Reyelts for creating Retroweaver and for making it freely available.

    Posted by: markswanson on May 19, 2005 at 06:15 PM

  • Ughm, how can you be sure that JAXB 2.0 doesn't use new classes that were not present in 1.4 at all? And if not now, maybe in future releases? JAXB 2.0 team has repeatedly pointed out the fact that they are not going to backport it to 1.4.
    And suppose you manage to do this, and people start using it. Then a bugfix minor release comes out that can not be ported to 1.4 (due to above reason). What about all those people. Are you going to be take the blame, or hold Sun responsible?

    Posted by: kirillcool on May 20, 2005 at 03:27 AM


  • Anything using @interfaces or enum types, for example, definitly does use 1.5-specific classes. There are workarounds for these specific 1.5 dependencies I think.

    I'm not sure at all there would be very many people interested in a backported JAXB 2.0 implementation. But the goal is to make something that is 1.5-source compatible, so that there is a consistent upgrade strategy, both for future JAXB releases to backport to 1.4, as well as for eventually migrating to 1.5.

    Posted by: jdcmember on May 20, 2005 at 07:22 AM

  • So, let's see from the Retroweaver documentation page:
    If you're using a class that is new to JDK 1.5, stop. Retroweaver has support for a few special classes (java.lang.Enum, java.lang.Iterable, and java.lang.StringBuilder), but that's it. You can't use any other classes that are new to JDK 1.5
    You can't use new JDK 1.5 classes/methods/fields in an earlier JVM.
    In this case, you are really counting on JAXB 2.0 developers not to use other 1.5 classes, such as java.util.Formatter, java.util.Scanner, java.util.Queue or java.util.EnumSet. But why shouldn't they?

    Posted by: kirillcool on May 20, 2005 at 11:39 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds