Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
kaushik_rukade
Posts: 12
Registered: ‎05-17-2011
My Device: 8900
My Carrier: IT

Need help to achieve backward compatibility from Java 1.6 to Java 1.4

Hi,

 

I have a Java 1.6 code and I need to use this for Blackberry  which is compatible with JDK 1.4. The prominent challenge I face here is the use of generics and collections in JDK 1.6 which are not supported by JDK 1.4.

 

1) I used Retrotranslator tool to convert 1.6 jar to 1.4 jar and added in my project. Project is now able to clean and build without any error, but if I access any of the API from that external 1.4 converted jar it is giving me build time error for the class where i used that API .
Error:: "Error preverifying class com.corp.type.json.TypeService[class of my project].

VERIFIER ERROR com/corp/type/json/AbstractJsonDataTypeProvider[class of that external jar].<init>()V:

Cannot find class java/util/Map"

 

2) Is there any way to achive backward compatibilty without using any tool.

 

Any pointers to achieve this backward compatibility with/without using tool would be helpful. Thanks in advance.

 

Thanks,

Kaushik

Please use plain text.
Developer
simon_hain
Posts: 15,940
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Need help to achieve backward compatibility from Java 1.6 to Java 1.4

i don't think you are allowed to implement stuff in the java.util package, but its been quite some time since i tried.
java.util.Map is not available, so you would have to replace that part of the code.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
kaushik_rukade
Posts: 12
Registered: ‎05-17-2011
My Device: 8900
My Carrier: IT

Re: Need help to achieve backward compatibility from Java 1.6 to Java 1.4

Thanks for your reply simon,

Here are my few questions

1) Can I use Retrotranslator tool to achive this backward compatibility. Converting 1.6 jar to 1.4 jar and use it in BB project (but still i am facing Error preverifying class issue. Is there any settings or additional steps i need to do?)

2) Shall I need to use 1.6 code only by replacing generics and collections from the entire source with corresponding available classes in BB?

Thanks,
Kaushik
Please use plain text.
Developer
simon_hain
Posts: 15,940
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Need help to achieve backward compatibility from Java 1.6 to Java 1.4

i am not familiar with the tool, but if it only generates a jar file and not the source code i would guess that you might get more issues.
I think J2ME is based on 1.3 and has some 1.4 features (check wikipedia or something to be sure), so you may run into other issues that you cannot address if you have only a jar.
if it supports output of actual code you could fix issues manually.
try outputting 1.3 code first, maybe it helps.

to do it manually would depend on the amount of code, i guess. The collections can be easily replaced, but generics may require some thinking (and work).
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.