I'm about to upgrade a tomcat installation from version 6.0 to version 8.5, and also upgrading the JVM from 6 to 8. Our java code is compiled with java 6 as for now.
I know that running java code on the latest JVM is always a good idea performance-wise (not to mention security-wise). In this way some code compiled with java 1.6 might run faster on JVM 8 compared to JVM 6.
But how about compilation? Does one gain anything by compiling code written in java 6 with a java 8 compiler (i.e. only java 6 features are used)? I.e. does code written with the intent of compiling with java 1.6 run faster on JVM 8 when the code is compiled with java 8 (targeted 8) and not java 6? Is the bytecode from java 8 optimized compared to java 6?
And regarding the target flag. Is anything gained by compiling java 6 code with a java 8 compiler targeted to java 6 (when the code is still to be run on JVM 6), compared to if the code was compiled with a java 6 compiler?