简体   繁体   中英

Java 1.4 Class performance on 1.5 JVM

Switching from JVM 1.4 to 1.5 has performance benefits as per release notes. http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#performance

We have Java 1.4 compiled classes which are run on 1.5 JVM, will these classes suffer in performance because they were compiled using 1.4 ?

Many of these features are "syntactic sugar". Meaning the language has new features, but it compiles to the same bytecode. So no, you shouldn't suffer in performance. Same bytecode on an updated VM.

"J2SE 5.0 is strongly compatible with previous versions of the Java 2 platform. Almost all existing programs should run on J2SE 5.0 without modification. However, there are some minor potential source and binary incompatibilities in the JRE and JDK that involve rare circumstances and "corner cases" that we are documenting here for completeness." -Sun/Oracle

http://java.sun.com/j2se/1.5.0/compatibility.html#incompatibilities

Also, depending on who coded your 1.4 classes, they may have had intimate knowledge of a particular VM/gc implementation and optimized for that. Not likely, but who knows.
The best way to know hos something performs is to run & profile. "Measure, don't guess."

Actually string operations will be faster in the classes compiled for 1.5 because the class StringBuilder can be used instead of StringBuffer. StringBuilder is a non-synchronized version of StringBuffer that was introduced in 1.5.

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