aspose file tools*
The moose likes Features new in Java 7 and the fly likes Migration from Java 5/6 to Java7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Features new in Java 7
Bookmark "Migration from Java 5/6 to Java7" Watch "Migration from Java 5/6 to Java7" New topic
Author

Migration from Java 5/6 to Java7

Shyam Sunder V R
Greenhorn

Joined: Jul 29, 2008
Posts: 20
Hi Guys,
I am working for a client on migrating his applications from Java5/6 to Java7.I have already gone through the new features in Java7 like try-with resources,Switch with strings,etc.
My client's idea of migration is NOT TO change the code (as much as possible) during migration.Unfortunately that is not negotiable.Minor changes to code are ofcourse acceptable if it affects performance or if there is any deprication.
With this background in mind,I surfed through various resources on the web and could find only one glitch with JDK 1.7 in compariosn to JDK 1.6 (Not really sure if this is fixed in any of the new builds of java 7,if so please enlighten me on it)
It says that the hashmap is now designed to be force synchronised and would show performance issues in JDK 7 when compared to JDK 6.

I need your help from your experiences or migration projects of what are the aspects or code snippets that I need to validate in addition to compiling the code with JDK 7.Any help is appreciated.

E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
The API specs for HashMap.java here http://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html
say that
Note that this implementation is not synchronized.
Shyam Sunder V R
Greenhorn

Joined: Jul 29, 2008
Posts: 20
Thanks that really helps...Apart from that if someone could help in answering the other part of my question...

"I need your help from your experiences or migration projects of what are the aspects or code snippets that I need to validate in addition to compiling the code with JDK 7.Any help is appreciated"
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
Moves to Java 7 from 5 and 6 don't really require much (if anything at all). It's backwards compatible so if you are not allowed to make changes you can just start running the old code on on the new run time without affecting the logic. You can chose which parts you want to improve by using new language features based on their usefulness for your particular project.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14432
    
  23

Oracle is always very careful to keep new Java versions compatible with older versions. You should be able to run your code on Java 7 without changing anything (you don't even need to recompile your code).

There might be some minor issues, which Oracle explains in detail here: Java SE 7 and JDK 7 Compatibility


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
diksha singh neel
Greenhorn

Joined: Jul 28, 2013
Posts: 10
What appserver are you using?
Anurag Verma
Ranch Hand

Joined: Mar 30, 2012
Posts: 124

diksha singh neel wrote:What appserver are you using?


Is this question really required??
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

I haven't changed a thing since I went from Java 6 to Java 7, and I cannot actually recall coding anything specific to Java 6. Although some of the resources I tap into probably do so. If I'm not mistaken, Java 6 finally got annotations to be civilized.

I think you read the specs on HashMap wrong. A number of classes in their original implementations were synchronized, including Vector. When Sun began to seriously implement collections, the newer stuff was all non-synchronized, and a simple capability was supplied to make any particular instance of a collection be synchronized. The older, always-synchronized classes remain, however, and they continue to be synchronized, just discouraged in favor of the default-unsynchronized classes. Hence StringBuffer/StringBuilder, Vector/ArrayList, and so forth.


Customer surveys are for companies who didn't pay proper attention to begin with.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3611
    
  60

I'm probably late to the game, but isn't this the issue in question: http://stackoverflow.com/questions/14010906/given-that-hashmaps-in-jdk1-6-and-above-cause-problems-with-multi-threading-how ?

In short, creating lots of HashMaps in Java 7 no longer scales well.
adam bilyone
Greenhorn

Joined: Aug 14, 2011
Posts: 16
Tnx
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
It said on that SO thread that JDK7u40 had fixed that problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Migration from Java 5/6 to Java7