assertj: Illegal reflective access warnings with SoftAssertions and Java 9+
Using AssertJ 3.9.0 and JUnit 5 with Maven Surefire 2.19, I get the classic Java 9 warning:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.assertj.core.internal.cglib.core.ReflectUtils$1 (file:.../org/assertj/assertj-core/3.9.0/assertj-core-3.9.0.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 org.assertj.core.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
When I use Assertions
instead of SoftAssertions
, the warning doesn’t show.
My environment:
$ java -version
openjdk version "9.0.1"
OpenJDK Runtime Environment (build 9.0.1+11)
OpenJDK 64-Bit Server VM (build 9.0.1+11, mixed mode)
$ uname -a
Linux sagan 4.15.0-0.rc8.git0.1.fc28.x86_64 #1 SMP Mon Jan 15 17:04:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
I have a suspicion that this is somehow related to either JUnit 5 or Maven Surefire 2.19. When I used JUnit 4 with Maven Surefire 2.20, AssertJ threw no warnings.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (10 by maintainers)
Commits related to this issue
- Illegal reflective access warnings with SoftAssertions and Java 9+ (fixes #1165) SoftAssertions: Replace writing to private field detailMessage of Throwable with creation of a new Throwable. — committed to PascalSchumacher/assertj-core by PascalSchumacher 5 years ago
- Illegal reflective access warnings with SoftAssertions and Java 9+ (fixes #1165) SoftAssertions: Replace writing to private field detailMessage of Throwable with creation of a new Throwable. — committed to PascalSchumacher/assertj-core by PascalSchumacher 5 years ago
- Illegal reflective access warnings with SoftAssertions and Java 9+ (fixes #1165) SoftAssertions: Replace writing to private field detailMessage of Throwable with creation of a new Throwable. — committed to PascalSchumacher/assertj-core by PascalSchumacher 5 years ago
Latest master works for me with Corretto 11.0.3_7 and JUnit 5.5.0
Thanks for fixing this so quickly!
I’m no longer seeing this issue with today’s master. My environment is as follows:
Thanks for the fix!