I have seen the compile options like discussed in Which JDK's distributions can run `javac -source 1.6 -target 1.5`?. I understand the individual options for source and
Peter Tseng does mention a lot of key points to remember during compilation. As a matter of fact even I faced a similar issue sometime back and want to share the root causes of many issues.
I had a source code which had to compiled & make it compatible (-source & -target) Java '1.8'. The code itself had
java.sql.*
packageAfter certain changes I ended up with a code which had equal amount of JUnit test cases to run. Eventually I bumped into a java.lang.VerifyError
. I was shocked when I understood that such error happens when I compile and run the code in the different libraries/environment(Which was not the case).
What I almost missed was that, for honoring the fact that the tests had to run in an isolated environment, the Junit & its test cases where executed in a seperate forked VM
This obviously will be spanned as a separate process and act as a standalone application in execution. Even though the IDE spans both processes synchronously, the JVM's are pretty much isolated.
After Java 1.7, Oracle has introduced a stricter verification and changed the class format a bit -- to contain a stack map, used to verify that code is correct. The exception I had seen was because some method doesn't have a valid stack map. I eventually tried including lot of JVM options to tweak the setting, but in vain.
nothing worked. The only work around was to include
In Java 1.7 to allow only nominal byte code verification. Since this was taken off in Java 1.8, the only option was to use