Description
When mvn test
is run with JDK 9 or later, there are multiple JUnit test failures. E.g., when using OpenJDK 11, here are the failures:
[ERROR] Tests run: 19, Failures: 0, Errors: 19, Skipped: 0, Time elapsed: 1.818 s <<< FAILURE! - in org.owasp.esapi.filters.SecurityWrapperResponseTest
[ERROR] Tests run: 16, Failures: 0, Errors: 16, Skipped: 0, Time elapsed: 1.939 s <<< FAILURE! - in org.owasp.esapi.reference.DefaultValidaterDateAPITest
[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.034 s <<< FAILURE! - in org.owasp.esapi.reference.crypto.EncryptedPropertiesUtilsTest
[ERROR] Tests run: 10, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.062 s <<< FAILURE! - in org.owasp.esapi.reference.crypto.ReferenceEncryptedPropertiesTest
[ERROR] Tests run: 18, Failures: 9, Errors: 9, Skipped: 0, Time elapsed: 2.012 s <<< FAILURE! - in org.owasp.esapi.reference.DefaultValidatorInputStringAPITest
[ERROR] Tests run: 4144, Failures: 0, Errors: 40, Skipped: 0
This problem seems to be related to Java Platform Module System (JPMS) which was first introduced in Java 9. (See the Guice GitHub issue referenced below.)
The first clue about this is the Maven error that appears for any Maven goal and
looks like this (at least for Maven 3.6.0):
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
which @jeremiahjstacey tracked down to Google Guice issue 1133 which has been open since 2017 and is apparently related to JPMS. Maven uses Google Guice, as does Eclipse, so we need to address these issues before Oracle JDK 8 is scheduled for end-of-life (tentatively for end of December, 2020; see https://www.oracle.com/technetwork/java/java-se-support-roadmap.html for details).