简体   繁体   中英

Performance difference between source-code targeted at different Java versions?

I have a 1.5 compatible Java source which will run solely on 1.8 VM and wondering whether it would be beneficial to target 1.8 during compilation instead of an older version.

Would there be any performance difference between 1.5 vs 1.8? Is there any relevant documentation or change-logs available which I could take a look at??

Since the compiled Java code you are referring to is the Java Byte code, running your old application with a new JVM version (1.8) should improve the performance of your application without the need of a recompilation of the byte code.

You can have a look at the Oracle official documentation regarding JDK 8 performance improvement to understand whats changed.

The javac does almost no optimisation. The main optimisation it does is constant inlining and it has always done this.

The difference is entirely in the JVM. In Java 8 you have more options to write the same code, which means you can re-write code to make it more efficient.

I usually set the compilation to 1.7. The new lambda syntax among other features of java 8 is nice to have, but I run into far less compatibility issues with java 7, and it's what I'm used to.

If you use the VM to work in yourself, and you know you don't have rely on frameworks that will end up with issues, by all means start with java 8. You can also check the official documentation, but Wikipedia actually provides a nice change log imo: https://en.wikipedia.org/wiki/Java_version_history

I found this Oracle source that discusses the compatibility of Java 7 with earlier versions. It mentions only the invokedynamic bytecode as a (bytecode) difference between version 7 and 6. Since the bytecode doesn't really change much, the effects of version 5 bytecode vs. version 8 bytecode on performance are negligible.

Except performance you should consider the thousand bug fixes which have been fixed since 1.5

There are also new APIs on 1.8 such as javafx , NIO , lambas.

Oracle announced that swing will not update anymore , so if your application has GUI you should consider to start looking for porting to javafx.

In oracle site btw when you download an new jdk there is also a link to it's changelog

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM