• Post Reply Bookmark Topic Watch Topic
  • New Topic

Migrating from 1.4.2 to 1.5 - advice?  RSS feed

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Herbert!

I am a program manager for my company and we have just finished a major release using 1.4.2. Now I have read about the exciting changes in 1.5 and I am wondering what the best way would be to go about migrating the current release of our application to use 1.5 for the next release.

Could you give any advice about this?

Many kind regards,
Rachel
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the application is working perfectly without the features of JDK 1.5, then you don't need to worry about this... Is there any other features that you want to add to your application from JDK 1.5? If not, I would suggest you to go on with JDK 1.4... But if you do want to develop things using JDK 1.5, use it when you start to develope another new application...
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I (for fun and testing) compiled our application (over 500 classes at the time) using 1.5.0 I found I needed to change exactly 1 variable name to make everything compile with only some lint warnings (which are to be expected in any pre-1.5 code).
It ran perfectly after I hacked the 1.5 runtime into Tomcat 4. If anything it seems faster than on 1.4.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ko Ko Naing:
If the application is working perfectly without the features of JDK 1.5, then you don't need to worry about this... Is there any other features that you want to add to your application from JDK 1.5?


Being able to use 5.0 features, such as generics, enhanced for loop, autoboxing, concurrency classes etc. can greatly simplify code. For ongoing projects, switching to 5.0 makes much sense to me, therefore.

But if you do want to develop things using JDK 1.5, use it when you start to develope another new application...


Not everyone has the luxury of being able to start a new greenfield project every year. The application I'm working on is in development (and in production) for over six years now, and we don't expect it to die in the short future.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We started by running our automated tests under JRE 5.0. Now selected customers run our system under JRE 5.0 for some time. Step by step we will try to get all of them using JRE 5.0. Then we can switch to compiling with JDK 5.0, and finally start to use the new features.
 
Herb Schildt
Author
Ranch Hand
Posts: 253
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rachel:

Here is a good way to start.

First, compile the code as-is using JDK 5. You will probably get some warnings about "raw types". These warnings relate to the use of classes that have been upgraded to generics in JDK 5. For the moment, ignore those warnings. But, respond to any other warnings or errors (if any). Once the code compiles cleanly (except for the warnings about raw types), test the code just to be sure there are no un-expected side-effects.

For those who are unfamilar with the term "raw-type", here is brief explanation: Because generics is a new feature, it was necessary for J2SE 5 to provide a transition path from old, pre-generics code. Remember, there are millions and millions of lines of pre-generics, legacy code that must remain both functional and compatible with generics. That is, pre-generics code must be able to work with generics, and generic code must be able to work with pre-generic code.

To handle the transition to generics, J2SE 5 allows a generic class to be used without any type arguments. This creates a raw type for the class. This raw type is compatible with legacy code, which has no knowledge of generics. The main drawback to using the raw type is that the type safety of generics is lost. This is why raw types generate compile-time warnings.


Second, respond to the raw-types warnings by adding the generic type parameters required to convert a raw type into a generic type. One of the most common places that you will encounter this issue is when using any part of the Collections Framework. Once your compiles are clean, test the application again.

Third, now you can begin look for places in which explicit boxing can be replaced by autoboxing. This is not necessary, but would bring your code into line with the modern approach.

Fourth, look for "magic numbers" that can be made into an enumeration. Enumerations add significant struture to code that relies on several constants. Keep in mind that Java enumerations are more powerful than enumerations found in other languages because they are class types.

At this point, you can begin to analyze the rest of your code for any other places in which feature such as varargs, the for-each style for, or static important will help add structure.

One last point: I have personally had very little trouble moving code to JDK 5.
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the great advice. I am glad to see that there are people moving over to 1.5 without hassle and that is really encouraging to me.

Also thank you for the specific advice about what we will encounter when we do start to migrate. That has been enough to boot me into migrating!

Many thanks!
Rachel
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!