• Post Reply Bookmark Topic Watch Topic
  • New Topic

Migrating From 1.4 To 1.8  RSS feed

 
Simon Ritchie
Ranch Hand
Posts: 134
4
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I've been assigned the task of upgrading an application from Java 1.4 to 1.8.  It's a rather extensive Java application that runs on a Unix server.  The build tool is Ant and from checking its build.xml file I don't see anything in there that specifies what version of Java to use.  I don't imagine that there will be too many changes that I have to make to the source code but as I've not handled a project like this before I was wondering if there are any guides or best practices to follow when migrating between different versions of Java.  All suggestions would be welcome.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Backward compatibility has been a top priority in the development of the Java language and the JVM, so in principle you should not need to make many changes to make the old code work on Java 8. There can, however, always be things that don't work.

However... There have been huge changes to the Java programming language since Java 1.4. For example, generics and many other language features were added in Java 5, and more new language features in Java 6, 7 and 8. The source code of your old application is most likely hopelessly outdated, and if you want to modernize it it's going to be a LOT more work than just doing the minimal things to get it running on Java 8.

Is the software using any frameworks or libraries? It's probably using very old versions of these too.

Ant is also a very old build tool, most more modern Java projects use Maven (or maybe Gradle).
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to check for the use of assert and enum anywhere in that code. They are new keywords, so code containing those words as identifiers will no longer compile. Actually, that problem may only apply to enum because I think assert was already a keyword in JDK1.4. You can find out by the simple technique of compiling the entire code to run on Java8/9 and looking for compiler errors. You may also find that some API has been deprecated since JDK1.4.
The compiled code (bytecode) should run on any version of Java® ≥ 1.4, probably without any changes.
How much effort are you going to put into updating the code? It sounds like a lot of hard work to refactor all your Collections to be generic, or change all your loops into Streams, or change all your synchronizeds to lock.lock(); try{...} finally{lock.unlock();}
I think you may consider that is more effort than it is worth.
If it ain't broke, don't fix it.
Remember there is a risk of introducing errors by changing things.
 
Simon Ritchie
Ranch Hand
Posts: 134
4
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks both.

Jesper de Jong wrote:The source code of your old application is most likely hopelessly outdated, and if you want to modernize it it's going to be a LOT more work than just doing the minimal things to get it running on Java 8.


The code behind the application is almost certainly outdated (I can't say with authority as I wouldn't consider myself an expert on Java 8 or 9 and I didn't write the application itself - it predated my arrival in the company by several years).  However it isn't broken so there's no desire to fix it, or modernise its code.  We've simply been told to ensure that it runs on a later version of Java, namely Java 8.

Jesper de Jong wrote:Is the software using any frameworks or libraries? It's probably using very old versions of these too.


Yes, it's using older versions of both Spring and Hibernate.  Again, I'm very reluctant to go about changing those without extensive testing first and I don't think I have the time to be able to do that.  I could be wrong in saying that but it's a large enough application and I doubt just swapping in newer JARs would be all that's needed to upgrade.


Campbell Ritchie wrote:You need to check for the use of assert and enum anywhere in that code. They are new keywords, so code containing those words as identifiers will no longer compile. Actually, that problem may only apply to enum because I think assert was already a keyword in JDK1.4. You can find out by the simple technique of compiling the entire code to run on Java8/9 and looking for compiler errors. You may also find that some API has been deprecated since JDK1.4.


I've checked and I haven't found any instances of assert or enum in the code, so that aspect at least should be okay, thanks.

I've taken a look at the application architecture.  The application is triggered when a shell script is run that calls the application JAR and passes in a couple of arguments.  The shell script contains a variable that indicates what version of Java to use when launching the application from the command line.  The way our servers are set up, we have every version of Java going back to Java 1 in a utilities folder.  Java 8 is already installed on the server so I think all I need to do is just update the shell script to point at Java 8 rather than Java 4.  That is, I'll be updating the script in the Development environment and testing.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!