Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to test after changing only the source and target version

Tags:

java

We have been following the official Java migration guide to upgrade our application from Java 6 to Java 8. Unfortunately we haven't set source and target version to 1.8 to prevent the usage of new language features.

So currently we are compiling and executing our application with JDK 1.8 / JRE 1.8 but set source and target level to 1.6.

Nevertheless, we now even want to level up the source and target level for our applications to 1.8.

Does setting those properties only changes the allowed features for the compilation and the binary format of the classes or does the configuration changes the semantics of the application? We expect that there shouldn't be any known issues or incompatibility when updating the source and target version to a higher version, when staying on the same JRE for execution and JDK for compilation.

like image 754
AlexN Avatar asked Oct 28 '22 17:10

AlexN


1 Answers

Does setting those properties only changes the allowed features for the compilation and the binary format of the classes or does the configuration changes the semantics of the application?

It can actually change the semantics of the Java language. For example, the meaning of @Overrides changed between Java 5 and Java 6. (I can't recall any changes like that between Java 6 and Java 8, but ....)

And of course:

  • There will be library bug fixes.
  • There will be cases where methods or classes are re-implemented (e.g. Arrays.sort and HashMap) with differences in unspecified aspects of library behavior.
  • Changes to the JIT compiler can lead to native code being optimized differently which can lead to timing or memory model-related regressions in (your) buggy multi-threaded code.

In short, even though upgrading from one version to the next ... or just changing the --source or --target is usually innocuous, it can sometimes lead to problems that need to be fixed.

So ... test everything ... thoroughly. Don't assume that it will all just work when you roll our the newer version.

Of course, it is advisable to read the lists of bug fixes and incompatibilities in the respective release notes. But be aware that the lists may be incomplete, or that you won't realize that some fix impacts your code. (Who knows / remembers every implementation detail of an large application written many years go?) And be aware that the fixed bug lists in a new major release are incremental from a previous patch release.


The counterpoint is that, you can't just defer upgrading because. The longer you put it off, the harder it becomes and the larger your codebase's technical debt becomes. And you may find yourself having to do the upgrade in a panic; e.g. due to an unpatched security problem, an OS support issue, and so on.

like image 186
Stephen C Avatar answered Nov 15 '22 05:11

Stephen C