• Post Reply Bookmark Topic Watch Topic
  • New Topic

Migrating Project from java 1.4 to 1.5  RSS feed

 
v ray
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
Recently, we decided to migrate our project from java 1.4 to 1.5. So now I'm supposed to check out the entire code and make changes wherever necessary.
We have decided to leave out certain changes though, for example:
1. We wont use for each loop as it is slow.
2. auto boxing is not being used.

However, so far I have:
1. Replaced StringBuffer with StringBuilder wherever possible.
2. Introduced generics for all the collections used.


Any other aspects of Java 1.5 worth using?? Please suggest all options.

Thanks a lot.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There were lots of changes from Java 1.4 to Java 5. You might want to read the Taming Tiger series over at DeveloperWorks if anything else applies to your project.

But it can't possibly be "necessary to make changes". If the app runs under Java 1.4, then it runs under Java 5, without any changes. To change code simply for the sake of using new language features seems dubious to me. I'd do that in those pieces of code that are being worked on in the future, or where it has an obvious functional benefit, but not for the sake of simply using new features.
[ July 01, 2007: Message edited by: Ulf Dittmer ]
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by v ray:
Hi guys,
Recently, we decided to migrate our project from java 1.4 to 1.5. So now I'm supposed to check out the entire code and make changes wherever necessary.
We have decided to leave out certain changes though, for example:
1. We wont use for each loop as it is slow.


Why do you think the new for-loop syntax is slow? I've never heard anything about this. The new for-loop syntax is only a different way of writing a for-loop. It isn't slower than an old-style for-loop with an interator.

Look at this program:

The two for-loops do exactly the same, the first one is with the old style loop and the second want with the new style. If you compile this code and then disassemble it with javap, you will see that the code with the new style loop has fewer bytecode instructions (about 18 instructions for the old loop, 14 for the new loop). So in this case, the new loop would probably be faster than the old loop.
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any point of code where Java 1.5 would fail?
 
v ray
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But it can't possibly be "necessary to make changes". If the app runs under Java 1.4, then it runs under Java 5, without any changes. To change code simply for the sake of using new language features seems dubious to me. I'd do that in those pieces of code that are being worked on in the future, or where it has an obvious functional benefit, but not for the sake of simply using new features.



Thanks a lot for the link, I found it really helpful and I will keep referring back to it for some time to come!
About the "necessary" changes part, ofcourse, although the code compiles without problems, there seem to be some better ways of doing things in java 1.5 and the project manager wanted to implement that. This is good for me anyway, as by doing this, I'm getting more familiar with the code(I'm new to this project).


If you compile this code and then disassemble it with javap, you will see that the code with the new style loop has fewer bytecode instructions (about 18 instructions for the old loop, 14 for the new loop). So in this case, the new loop would probably be faster than the old loop.


This is very interesting, I will bring this up with the manager and I definitely see the sense in what you are saying. Thanks!
 
Farhan Jan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

My question is Opposite, to the discussion going on!

I have my code in jdk 1.5, but I have a requirement to use my application's jar file in jdk1.4

I can obviously conevrt the codeto be jdk.14 compatible, by removing generics and stuff., But I wonder, Is it possible to use my jar file 'AS IT IS' , without recompiling in jdk 1.4
and just adding some files in lib of my jdk1.4 application???

urgently need guidence!!
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have my code in jdk 1.5, but I have a requirement to use my application's jar file in jdk1.4


This is really a hijack here, so let's not start a whole new conversation on a different topic. There are libraries that can transform Java 5 code to Java 1.4 code to a limited degree, e.g. RetroWeaver. For any further questions on this topic, please start a new thread.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!