Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 263393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:35:53+00:00 2026-05-11T22:35:53+00:00

We are stuck with Java2SE v1.4 till the end of 2010. That’s really nasty,

  • 0

We are stuck with Java2SE v1.4 till the end of 2010. That’s really nasty, but we can’t help it. What options do we have to use some of the new features already now? I can think of several ways like

  • changing the bytecode, e.g. using Retrotranslator or Retroweaver.

  • backport of libraries, e.g. Concurrent Backport, but this does not help for generics.

  • emulation of Java 5 features, e.g. checked Collections, Varargs with helper methods, etc.

  • changing source code by precompilation, stripping all 1.5 stuff before final compilation, e.g. using Declawer can do this.

I am most interested in very positive experience with it in production environments using Weblogic and “real” stuff.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:35:53+00:00Added an answer on May 11, 2026 at 10:35 pm

    Thanks for your answers. Here is the summary of all relevant answers and my own research.

    Changing the bytecode: The Retros
    This is done by the “retro”-tools: Retrotranslator, Retroweaver and JBossRetro. Retrotranslator seems to be the most mature
    and active of them tool. These tools scan all classes and change the bytecode to remove Java 5 and 6 features. Many Java5 features are supported, some
    by using 3rd party backport libraries. This option is most popular and there is some positive feedback from users. Experiments showed that it’s working as
    expected. See a short overview on developerworks.

    Pro: You can develop entirely in Java 5, build modules and all kind of JARs. In the end you just transform all classes to Java 1.4 and package your EAR.
    This is easily done with Retrotranslator’s Maven integration (org.codehaus.mojo:retrotranslator-maven-plugin).

    Con: Conservative environments do not allow changed bytecode to be deployed. The result of the retro-step is not visible to any coder and can’t be approved.
    The second problem is fear: There might be some cryptic production problem and the retro-code is another step that might be blamed for that. App-server vendors
    might refuse help due to changed bytecode. So nobody wants to take responsibility to use it in production. As this is rather a policital than a technical
    problem, so I see no solution. It has happened to us, so I was looking for further options 🙁

    Compiling Java5 to Java 1.4: jsr14
    There is an unsupported option, javac -source 1.5 and -target jsr14 which compiles the Java5 source to valid Java 1.4 bytecode. Most features like
    varargs or extended for loop are translated by the compiler anyway. Generics and annotations are stripped. Enums are not supported and I don’t know
    about autoboxing, as the valueOf methods were mostly introduced in Java5.

    Con: Only byte code is translated, library usage is not changed. So you have to be careful not to use Java5 specific APIs (but could use Backports).
    Further you have to build all modules at the same time, because for development time you propably want Java5 code with generic and annotation information.
    So you have to build the entire project from scratch for Java 1.4 production.

    Changing Source back to Java 1.4: Declawer
    As answered in a related question, there is Declawer, a compiler extension, that works for generics and varargs, but not for enhanced for loop or
    autoboxing. The generated source “is a little funky, but not too bad”.

    Pro: The generated source is available and can be reviewed. In worst case fixes can be made in this source. There is no “magic”, because the source
    is valid Java. Some people even use JAD (Java decompiler) to get the Java 1.4 source again. The output of Jad readable is readable if you compile with debug
    information and don’t use inner classes.

    Con: Similar to -target jsr14, you need an extra step in the deployment. Same problems with libraries, too.

    Changing Source back to Java 1.4: by hand
    Several answers suggested doing it by hand. For an automatic, repeating build process this is of course not useful, but for one-time changes it’s
    reasonable. Just automate what is possible. Maybe look at Antlr for creating a home-grown conversion tool.

    Backported Libraries:
    The problem is, that Java5 also ships new libraries, that are not available in older JREs, see related question. Fortunately there are several
    backported libraries that give you some functionality of Java5, but can’t simulate language features, like generics.

    • Annotations, discussed at TSS
    • Concurrent
    • com.sun.net.httpserver (Java 6 to 5)
    • Gif writing (Java 6 to 5)
    • Start your own backport project 😉
    • You might copy classes you need from the JDK or other libraries, but most likely they are related to other classes.

    Emulating Java5 features in Java 1.4 code:
    I was thinking about some things you might do to make your life easier and still staying with Java 1.4. The most important features are typesafe collections,
    here are some ideas:

    • Instead of using generics you can create your own typesafe containers with some template.
    • Add a typesafe Iterator (which is no Iterator any more).
    • Add asList methods that allows 1,2,...,n arguments and an array of them (to simulate varargs).
    • Methods for varargs (converting 1,...,n arguments to arrays) and valueOf can be put in some helper class.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Stuck with this particular issue. I have code that get lots of pages from
Really stuck on what seems to be something simple. I have a chatbox/shoutbox where
Stuck with a silly problem. I have an input field, where user can input
I stuck here need help Ruby on rails I have one Pop-up for login
Stuck on KVCs in Obj-C again. I am wanting to use KVC to find
Kinda stuck here... I have an application with lets say 5000 rows of data
Im stuck with this little project in C# but basically my problem is this:
I am doing an assignment and stuck at this point: I have a class
Stuck with a Wordpress query... It's proably obvious what i'm trying to do.... But
Stuck again. :( I have the following code crammed into a procedure invoked when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.