This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
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

Problem going from 1.5 to 1.4.2

 
Rob Marshall
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This is probably a really dumb question, but I'm not sure what to do with this. I'm relatively new to Java and I had written some stuff using 1.5 (that's working just fine) but I have to run it on a 1.4.2 system. Below is a simplified example of one of the problems and it has to do with HashMaps. The 1.5 code is:

When I try to compile this on 1.4.2 it complains about the <String, ...> bits. So I took them out but then when I try to compile it I get:

I'm assuming that this is probably something really simple, but I don't know what it is. Any ideas?

Thanks,

Rob
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to get rid of all the generic type declaration you use with you Maps, List etc.

These were introduced in Java 1.5

So instead of



you need to use this syntax



 
Rob Marshall
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sebastian,

Thanks for the quick response, but what it's complaining about is the get(). Even if I do:


It still complains about:

So the problem seems to be with the get() method for the HashMap, not with the type of the data being returned/gotten.

Rob
 
Rob Marshall
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, what I have to do is (and again, thanks for the tip because it got me thinking...):

I had originally made the assumption (bad as it turns out) that it was the first get(), when it was actually the second one that it was complaining about.

Thanks again,

Rob
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should check the 1.4 API docs then.

Another option is to use something like retroweaver/retrotranslator which AFAIK will convert essentially all 1.5 bytecode to be 1.4-compatible, but you'd have to try it.
 
Rob Marshall
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

Thanks for the information about retroweaver/retrotranslator. I have retrotranslator working and everything seems to be fine (hallelujah! I was really dreading have to track down all the stuff I'd have to change...). I wasn't able to build retroweaver, the ant build.xml (I think it's actually the build.properties) is set up for Windows and not Linux so it doesn't find the 1.4 JVM even when I change the build.properties file. Right now I don't feel like messing with it. Maybe I'll get back to it later...unless someone here knows of a build.Linux.properties for it

Thanks again,

Rob
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic