jamm
jamm copied to clipboard
Tests fail with OpenJDK 17 due to an illegal reflective access
While running tests with OpenJDK 17 a failure occurs due to an illegal reflective access into java.base/java.lang:
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.github.jamm.MemoryMeterTest
[ERROR] Tests run: 20, Failures: 1, Errors: 2, Skipped: 5, Time elapsed: 0.147 s <<< FAILURE! - in org.github.jamm.MemoryMeterTest
[ERROR] testPrimitives(org.github.jamm.MemoryMeterTest) Time elapsed: 0.005 s <<< ERROR!
java.lang.reflect.InaccessibleObjectException: Unable to make field private final byte[] java.lang.String.value accessible: module java.base does not "opens java.lang" to unnamed module @768debd
at org.github.jamm.MemoryMeterTest.testPrimitives(MemoryMeterTest.java:443)
[ERROR] testUnmeteredAnnotationOnFields(org.github.jamm.MemoryMeterTest) Time elapsed: 0.001 s <<< ERROR!
java.lang.reflect.InaccessibleObjectException: Unable to make field private final byte[] java.lang.String.value accessible: module java.base does not "opens java.lang" to unnamed module @768debd
at org.github.jamm.MemoryMeterTest.testUnmeteredAnnotationOnFields(MemoryMeterTest.java:614)
[ERROR] testByteBuffer(org.github.jamm.MemoryMeterTest) Time elapsed: 0 s <<< FAILURE!
java.lang.AssertionError: Shallow empty ByteBuffer expected:<48> but was:<56>
at org.github.jamm.MemoryMeterTest.testByteBuffer(MemoryMeterTest.java:478)
[INFO] Running org.github.jamm.GuessTest
Guessed 16, instrumented 24 for {LONG*1}->{FLOAT*1}
Guessed 16, instrumented 24 for {LONG*1}->{BYTE*4}
[ERROR] Tests run: 4, Failures: 1, Errors: 0, Skipped: 3, Time elapsed: 0.418 s <<< FAILURE! - in org.github.jamm.GuessTest
[ERROR] testProblemClasses(org.github.jamm.GuessTest) Time elapsed: 0.385 s <<< FAILURE!
java.lang.AssertionError: Not all guesses matched the instrumented values. See output for details. expected:<0> but was:<2>
at org.github.jamm.GuessTest.testProblemClasses(GuessTest.java:85)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] GuessTest.testProblemClasses:85 Not all guesses matched the instrumented values. See output for details. expected:<0> but was:<2>
[ERROR] MemoryMeterTest.testByteBuffer:478 Shallow empty ByteBuffer expected:<48> but was:<56>
[ERROR] Errors:
[ERROR] MemoryMeterTest.testPrimitives:443 » InaccessibleObject Unable to make field p...
[ERROR] MemoryMeterTest.testUnmeteredAnnotationOnFields:614 » InaccessibleObject Unabl...
[INFO]
[ERROR] Tests run: 24, Failures: 2, Errors: 2, Skipped: 8
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
I just started using jamm
today and immediately bumped into a similar issue. It is related to changes introduced in JDK 9 concerning module security. See this. TL;DR, you can add --add-opens
directives as command line options, like this:
--add-opens java.base/java.lang=ALL-UNNAMED
For my particular case, I had to add about 20 of them!
Thanks for the pointer @ashatch!
Even with --add-opens there are failing tests unfortunately
INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.github.jamm.MemoryMeterTest
[ERROR] Tests run: 20, Failures: 1, Errors: 0, Skipped: 3, Time elapsed: 0.444 s <<< FAILURE! - in org.github.jamm.MemoryMeterTest
[ERROR] testByteBuffer(org.github.jamm.MemoryMeterTest) Time elapsed: 0.004 s <<< FAILURE!
java.lang.AssertionError: Shallow empty ByteBuffer expected:<48> but was:<56>
at org.github.jamm.MemoryMeterTest.testByteBuffer(MemoryMeterTest.java:478)
[INFO] Running org.github.jamm.GuessTest
Guessed 40, instrumented 120 for {BOOLEAN*7 OBJECT*20 FLOAT*3 SHORT*1}->{BYTE*1}
Guessed 648, instrumented 808 for {LONG*2 LONG*4 SHORT*1 SHORT*1 SHORT*1}->{FLOAT*35 DOUBLE*11 SHORT*28 DOUBLE*3}->{DOUBLE*33 OBJECT*37 BYTE*3 OBJECT*3}->{BYTE*1 BOOLEAN*2}
Guessed 16, instrumented 24 for {LONG*1}->{FLOAT*1}
Guessed 16, instrumented 24 for {LONG*1}->{BYTE*4}
[ERROR] Tests run: 4, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 13.542 s <<< FAILURE! - in org.github.jamm.GuessTest
[ERROR] testRandomClasses(org.github.jamm.GuessTest) Time elapsed: 12.208 s <<< FAILURE!
java.lang.AssertionError: Not all guesses matched the instrumented values. See output for details. expected:<0> but was:<2>
at org.github.jamm.GuessTest.testRandomClasses(GuessTest.java:116)
[ERROR] testProblemClasses(org.github.jamm.GuessTest) Time elapsed: 1.096 s <<< FAILURE!
java.lang.AssertionError: Not all guesses matched the instrumented values. See output for details. expected:<0> but was:<2>
at org.github.jamm.GuessTest.testProblemClasses(GuessTest.java:84)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] GuessTest.testProblemClasses:84 Not all guesses matched the instrumented values. See output for details. expected:<0> but was:<2>
[ERROR] GuessTest.testRandomClasses:116 Not all guesses matched the instrumented values. See output for details. expected:<0> but was:<2>
[ERROR] MemoryMeterTest.testByteBuffer:478 Shallow empty ByteBuffer expected:<48> but was:<56>
[INFO]
[ERROR] Tests run: 24, Failures: 3, Errors: 0, Skipped: 3
We are working on having Jamm ready for JDK17 and this issue is in our pipeline with many others. Hopefully it should be fixed in the 2 coming weeks.
The current master version should work smoothly with the JDKs up to 17.
Great, thanks a lot! Are you planning a release with this fix?
Yes. We plan to run some tests with Apache Cassandra in the coming weeks to make sure that there is no issues that we have missed and once it looks good we will make an official release. We also plan to add support for the latest JDK versions after that release.
Great, thanks!