Skip to content

Commit

Permalink
Module java.base opens package java.lang to unnamed module
Browse files Browse the repository at this point in the history
This is only for JDK >= 16.

Without this fix some unit tests that uses Mockito will fail with the
following error:

```
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 @cafebabe
```

We notice this error only after upgrade JaCoCo to version 0.8.9 because
prior this version the error was being hide by a side effect of JaCoCo.

See: jacoco/jacoco#1334
See: jacoco/jacoco#1328
See: #86 (comment)
See: #86 (comment)
See: #86 (comment)
See: #87

This is a workaround and the added profile should be removed in the
future in order of a definitive fix (maybe Mockito upgrade).

This reverts commit 31a8d68.
  • Loading branch information
andrioli committed Mar 6, 2024
1 parent 31a8d68 commit cc461cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jaguar2-build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<maven.compiler.source>${source}</maven.compiler.source>
<maven.compiler.target>${bytecode}</maven.compiler.target>
<ba-dua.version>0.8.0</ba-dua.version>
<jacoco.version>0.8.8</jacoco.version>
<jacoco.version>0.8.9</jacoco.version>
<gpg.skip>true</gpg.skip>
</properties>

Expand Down
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@
<additionalJOption>-html5</additionalJOption>
</properties>
</profile>
<profile>
<id>mockito-add-opens</id>
<activation>
<!-- Required only for Java >= 16 -->
<jdk>[16,)</jdk>
</activation>
<properties>
<argLine>--add-opens=java.base/java.lang=ALL-UNNAMED</argLine>
</properties>
</profile>
<profile>
<id>animal-sniffer-bytecode-java21</id>
<activation>
Expand Down

0 comments on commit cc461cd

Please sign in to comment.