• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java 5 to 6 migration.  RSS feed

 
Shankara Sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

We are planning to migrate our application from java 5 to 6.

So can you please suggust me what are all the improvements that can be made to our code base.

Our application is buit on the following technologies:

Java Threads
RMI
Generics
JDBC
and other core java API's.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why Java 6? It's obsolete and unsupported, and has security issues that are not going to be fixed. At this point you should move straight to Java 7.

Here's what's new in Java 6: http://www.oracle.com/technetwork/java/javase/features-141434.html

Here's what's new in Java 7: http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html
 
Paul Clapham
Sheriff
Posts: 22823
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course I know nothing about your code base, but the main features of Java 7 which I implemented into my code base were try-with-resources and catching multiple exception types.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:At this point you should move straight to Java 7.

Or possibly even 8?

@Shankara: The reason I say this is that v8 is now (AFAIK) released, so should therefore be "current" for at least the next 2 years; and I'm not sure of Oracle's policy about supporting past releases. If you go to v7, you may just have another migration job in a year or two when they decide to deprecate it; with v8 you should be good for at least 3 or 4.

And since (I assume) your migration won't happen immediately, you should have covered any "burn-in" time for the new release by the time you're ready to deploy your updated app.

As to what you include - that's too big a question to answer here. As Paul says, you need to read the release notes for the target version, and also any one that you're skipping. However, from the content you describe, I don't think you'll find any burning issues that need to be retro-fitted.

The only thing I would suggest is: migrate, compile and test first, then apply release-specific upgrades you think might be useful.

HIH

Winston
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
Ulf Dittmer wrote:At this point you should move straight to Java 7.
Or possibly even 8?


I would strongly recommend against moving a production application to what is essentially a .0 software version.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:I would strongly recommend against moving a production application to what is essentially a .0 software version.

Hmm. That would suggest that you think that production servers should be on a previous release.

Surely that puts an undue strain on software creaters, who are then doomed to support two previous versions at the very least - assuming a grandfather-father-son model. And given how long 1.4.2 was around, I suspect you could have a lot of staff turnover in that sort of timeframe.

All I'm saying is that you want it on a robust release; and it's what I've always advocated as a sysadmin - no "bleeding edge" stuff, but be as current as possible otherwise.

Just my opinion though.

Winston
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You misunderstood. I'm not advocating staying with Java 7 until Java 9 is out. I'm saying that migrating to the first release of a major software (like Java 8) would be reckless. Once release u5 or u10 is out it may have earned enough trust to be considered production ready. But not u0.

(I also disagree with what you said about putting a strain on software vendors - Oracle obviously does not support 2 versions back-but that's beside the point.)
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:You misunderstood. I'm not advocating staying with Java 7 until Java 9 is out. I'm saying that migrating to the first release of a major software (like Java 8) would be reckless. Once release u5 or u10 is out it may have earned enough trust to be considered production ready. But not u0.
(I also disagree with what you said about putting a strain on software vendors - Oracle obviously does not support 2 versions back-but that's beside the point.)

I fear we'll have to disagree on this one then, because I'd suggest that your paradigm unduly restricts both users and vendors of software. I've done major releases of not only software, but of databases and OS versions (potentially far more damaging), and with the right controls in place it can be done pretty easily. You simply need to trust the vendor (or, in Java's case, the supporter). If you don't, why did you buy into the plan in the first place?

And I'm not just taking about commercial software, where you can probably sue somebody if something goes wrong (now that's a bad paradigm). Linux is free to all, but has been around for enough time to have had its "upgrade" methods tested pretty well, and the great thing about shareware is that there are scads of forums like ours around to help you if you run into difficulties (like I did with Oracle 8i).

I think I understand where you're coming from, and for conservative institutions like banks and government departments it may well be good advice; but in more dynamic environments you need someone who is prepared (with the proper support and processes, of course) to simply turn off the servers, press the "Go" button (maybe with fingers crossed), and fire them up again.

That said, Shankara is coming from v5, so maybe dynamism isn't so important.

Winston
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, we definitely have different viewpoints. I don't think it restricts users much (I would argue that there's no sizable competitive advantage in making the switch soon) or vendors (as of the Java 6 EOL Oracle didn't even support one version back, at least not the free version). And to clarify, I'm not talking just about conservative institutions, I would advise this to all places that have something at stake, large or small, old or young.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Yeah, we definitely have different viewpoints...

I suspect it depends on what you're used to. I can certainly see that if you're already making a big jump (as Shankara is), it might be sensible to go to v7 first, but if you work in a shop that upgrades regularly, and has the tools and testbeds and processes to make it routine, I'd favour v8 (but maybe in a few month's time ).

Winston
 
Campbell Ritchie
Marshal
Posts: 56530
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds as if your viewpoints aren't very different.

I don't think this is a “beginning” topic, so I shall move it.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, the difference between Winston's "in a few month's time" and my "once release u5 or u10 is out" might not be all that much.
 
Shankara Sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to your suggestions. We are pushing our customer to migrate to Java 7.

I found few improvements that can made to our project's source code.
1. Replace System.arraycopy() with Arrays util class methods.
2. Change StringBuffer to StringBuilder.

Other these two are they any other code level improvements that can be made?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends on what your code does; maybe something in the release notes I linked to suggests itself?

Note that StringBuilder is not thread-safe, which may or my not make a difference in your case.
 
Shankara Sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Our source code mostly made up of Threads, JDBC, RMI, Genercis. So can you please suggest any improvements in those areas?

Note that StringBuilder is not thread-safe, which may or my not make a difference in your case.


Yeah but our code hevaily uses StringBuffer. So we are planning to replace that with StringBuilder.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shankara Sharma wrote:Yeah but our code hevaily uses StringBuffer. So we are planning to replace that with StringBuilder.

Which is fine, providing you don't need the synchronization that StringBuffer provides. Personally, I wish they'd add an interface (StringBucket? ) that both classes implement, so you can use them interchangeably.

A lot of the changes in 6 and 7 are what I would call "convenience" enhancements, that save you writing a lot of code; but whether it's worth retro-fitting them to code that already works, I'm not really sure.

In addition to the Arrays class, you might also want to have a look at Files (java.nio.file.Files) and Objects (java.util.Objects). The latter has a hash() method which takes an awful lot of effort out of writing hashCode() methods, and Files contains some very neat stuff too (indeed the whole java.nio package is worth looking at). But is it really worth retro-fitting all these things? Perhaps on an organic basis - ie, as you make other updates - but not a wholesale refactoring.

HIH

Winston
 
Shankara Sharma
Ranch Hand
Posts: 48
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finallly we are migrating our application from java 5 to 7.

Here are some interesting stuff in Java 7:

NIO API

http://tutorials.jenkov.com/java-nio/index.html
https://blogs.oracle.com/slc/entry/javanio_vs_javaio

File systems API

http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html

Fork/Join Framework

But be aware of the pit falls of Fork/Join framework.

http://coopsoft.com/ar/CalamityArticle.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!