Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Porting a source library in jdk 1.5 to jdk 1.4

 
Nishant Suneja
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have to port smack 3.1.0 library from jdk 1.5 to jdk 1.4.
I tried using Retroweaver an Retrotranslator tools for doing the job. However, i wasnt able to get through with either of those.
Is there any other tool available which could perform the job ?
If there isnt, i would have to use the brute force technique of converting the jdk 1.5 specific code ( generics, annotations, for-each loop etc. ) into jdk 1.4 compilant code.

Kindly help me out with this. Any material available on this topic would really help.
 
Robert Waals
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally I have never used this but you could try to the compile the code using the "-target 1.4" option from the java compiler (javac). I have also seen references stating you also have to target the compiler to the classes library of the Java 1.4 environment (for example: -bootclasspath jdk1.4.2/lib/classes.zip).

For more information: Javac

Regards,
Robert Jan
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert Waals wrote:Personally I have never used this but you could try to the compile the code using the "-target 1.4" option from the java compiler (javac).


That will work only if the code itself doesn't use any Java 5 features; that's not the case here.

In any case, translating for-loops and generics is actually pretty simple, and they're handled quite well by a tool like Retroweaver. Annotations can be harder, depending on what they're used for. "@Override" can just be erased, whereas J2EE-related and JUnit4 annotations probably require some human intervention to translate.

Do you know where Retroweaver is going wrong? Can you translate just that one feature by hand, then do the rest automatically?
 
Rob Spoor
Sheriff
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you perhaps using Iterable? Because Retroweaver explicitly states that it can have problems with that.
 
Nishant Suneja
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Retrotranslator tool worked fine when i tried it out again, with some newly accquired knowledge.
Its better than retroweaver, as it covers some of the jdk 1.5 specific features which retroweaver doesnt.
Thanks for all the replies though.
 
sagar bhagat
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nishant,

I am also having the same problem, have to port smack library in Java ME.

I am developing IM client in Java ME.

Through your discussion came to know that you have successfully ported the smack api into jdk 1.4.

Can you provide me the process of conversion, also whether you were able to use the library for Java ME.

Thanks in advance

Sagar

 
Nishant Suneja
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sagar

Regarding the conversion process, follow the procedure given in :: http://retrotranslator.sourceforge.net/.
You should be able to port the smack library from jdk 1.5 to jdk 1.4 .

And regarding your other query, I ran the library on J2SE 1.4, where it ran fine.
I didnt try it on Java ME. But, newhow, you can give it a try there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic