siom79 / japicmp

Comparison of two versions of a jar archive
https://siom79.github.io/japicmp
Apache License 2.0
701 stars 107 forks source link

Build with jdk17 fails #307

Closed snuyanzin closed 1 year ago

snuyanzin commented 2 years ago

Probably the reason is that since jdk 17 --illegal-access does not make any case as mentioned at https://openjdk.java.net/jeps/403 Build fails with

[ERROR] Tests run: 7, Failures: 0, Errors: 7, Skipped: 0, Time elapsed: 0.069 s <<< FAILURE! - in japicmp.maven.SkipModuleStrategyTest
[ERROR] testModuleIsNotIncludedAndNoIncludesDefined(japicmp.maven.SkipModuleStrategyTest)  Time elapsed: 0.065 s  <<< ERROR!
java.lang.ExceptionInInitializerError
    at japicmp.maven.SkipModuleStrategyTest.createMavenParameters(SkipModuleStrategyTest.java:96)
    at japicmp.maven.SkipModuleStrategyTest.testModuleIsNotIncludedAndNoIncludesDefined(SkipModuleStrategyTest.java:78)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @5f8754e
    at japicmp.maven.SkipModuleStrategyTest.createMavenParameters(SkipModuleStrategyTest.java:96)
    at japicmp.maven.SkipModuleStrategyTest.testModuleIsNotIncludedAndNoIncludesDefined(SkipModuleStrategyTest.java:78)
siom79 commented 2 years ago

The problem is that mockito currently does not support jdk17: https://github.com/mockito/mockito/issues/2212

Can be solved by upgrading to latest mockito version.

But javassist's CtClass.toClass() cannot be called with jdk17: https://github.com/jboss-javassist/javassist/issues/400 Currently this issue is not fixed.

chibash commented 2 years ago

I suppose that this issue can be fixed by changing mockito so that mockito will call CtClass.toClass(Class) or CtClass.toClass(Lookup), etc. Please see http://www.javassist.org/html/javassist/CtClass.html#toClass()

cstamas commented 2 years ago

This issue seems fixed, am building project with Java 17 all right:

[cstamas@urnebes japicmp (master)]$ mvn -V clean install
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /home/cstamas/.sdkman/candidates/maven/current
Java version: 17.0.3, vendor: Eclipse Adoptium, runtime: /home/cstamas/.sdkman/candidates/java/17.0.3-tem
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.18.6-200.fc36.x86_64", arch: "amd64", family: "unix"
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for japicmp-base 0.15.8-SNAPSHOT:
[INFO] 
[INFO] japicmp-base ....................................... SUCCESS [  0.504 s]
[INFO] japicmp ............................................ SUCCESS [  8.736 s]
[INFO] japicmp-testbase ................................... SUCCESS [  0.008 s]
[INFO] japicmp-test-v1 .................................... SUCCESS [  0.229 s]
[INFO] japicmp-maven-plugin ............................... SUCCESS [  4.143 s]
[INFO] japicmp-test-v2 .................................... SUCCESS [  1.518 s]
[INFO] japicmp-test2-v1 ................................... SUCCESS [  0.035 s]
[INFO] japicmp-test2-v2 ................................... SUCCESS [  0.041 s]
[INFO] japicmp-test ....................................... SUCCESS [  4.041 s]
[INFO] japicmp-test-maven-plugin .......................... SUCCESS [  4.158 s]
[INFO] japicmp-test-maven-plugin-guava .................... SUCCESS [  0.589 s]
[INFO] japicmp-test-maven-plugin-japicmp .................. SUCCESS [  0.189 s]
[INFO] japicmp-test-service-impl-base ..................... SUCCESS [  0.007 s]
[INFO] japicmp-test-service-v1 ............................ SUCCESS [  0.041 s]
[INFO] japicmp-test-service-v2 ............................ SUCCESS [  0.035 s]
[INFO] japicmp-test-service-impl-v1 ....................... SUCCESS [  0.040 s]
[INFO] japicmp-test-service-impl-v2 ....................... SUCCESS [  0.040 s]
[INFO] japicmp-test-service-test .......................... SUCCESS [  0.709 s]
[INFO] japicmp-test-maven-plugin-classifier ............... SUCCESS [  0.464 s]
[INFO] japicmp-test-maven-plugin-pom-module ............... SUCCESS [  0.020 s]
[INFO] japicmp-test-vx-client ............................. SUCCESS [  0.326 s]
[INFO] japicmp-test-maven-plugin-ignoremissingartifact .... SUCCESS [  0.117 s]
[INFO] japicmp-test-maven-plugin-packaging ................ SUCCESS [  0.347 s]
[INFO] japicmp-testbundle-v1 .............................. SUCCESS [  0.540 s]
[INFO] japicmp-testbundle-v2 .............................. SUCCESS [  0.054 s]
[INFO] japicmp-testbundle ................................. SUCCESS [  1.087 s]
[INFO] japicmp-test-maven-plugin-userproperty ............. SUCCESS [  0.453 s]
[INFO] japicmp-test-maven-plugin-post-analysis-script-artifact SUCCESS [  0.020 s]
[INFO] japicmp-test-maven-plugin-post-analysis-script-artifact-test SUCCESS [  0.880 s]
[INFO] japicmp-ant-task ................................... SUCCESS [  2.469 s]
[INFO] japicmp-test-ant-task .............................. SUCCESS [  0.837 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  33.428 s
[INFO] Finished at: 2022-06-27T11:49:41+02:00
[INFO] ------------------------------------------------------------------------
[cstamas@urnebes japicmp (master)]$