0

I'm in to process of upgrading from 1.6 to 1.8.

Because of this, I'm looking for a good way to list all dependencies that aren't Java 1.8 compatible. I've got JAVA_HOME is already set. and I'm using Maven 3.3.9.

I'm looking for something like:

mvn dependancy:compatabilityTest

Environment Info:

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T11:41:47-05:00)
Maven home: C:\Data\apps\apache-maven-3.3.9\bin\..
Java version: 1.8.0_112, vendor: Oracle Corporation
Java home: C:\Program Files (x86)\Java\jdk1.8.0_112\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "dos"
Tunaki
  • 132,869
  • 46
  • 340
  • 423
ScrappyDev
  • 2,307
  • 8
  • 40
  • 60
  • Do you have any reason to believe there are libraries running fine under Java 6 but not under Java 8? Thanks to JRE backwards compatibility, I suspect not. http://stackoverflow.com/questions/22610400/a-program-made-with-java-8-can-be-run-on-java-7 and http://stackoverflow.com/questions/4692626/is-jdk-upward-or-backward-compatible – Tunaki Nov 07 '16 at 19:57
  • Yeah, getting a `java.lang.IllegalStateException: Failed to transform class with name some.path.SomeClassTest. Reason: java.io.IOException: invalid constant type: 15 – ScrappyDev Nov 07 '16 at 20:03
  • There is no good reason a class is incompatible, it's not a standard thing but a rare bug. You really have to go out of your way to find such a case. – Peter Lawrey Nov 07 '16 at 20:09
  • I'm seeing it in Mockitto, or in a class that mockito is messing w/ as far as I can tell. Maybe it's a bug in mockito – ScrappyDev Nov 07 '16 at 20:14

1 Answers1

1

"Failed to transform class with name" most likely means byte code generation or transformation is being used. There is no way to determine this statically as the class doesn't exist in the form it will be loaded until the program is run.

Java 8 adds some validation to the byte code which wasn't in older versions. This means byte code generated in Java 5.0 which wasn't valid might not have failed but now it does. The solution is to upgrade the version of the byte code generator and most likely the library which uses it.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130