Bug: Illegal access warning logs visible on bin/tools invocations
Status: Resolved
Priority: Normal
Resolution: Fixed
Created: 18/Jul/24 13:52
Resolved: 23/Jul/24 15:00

There is discrepancy between what opens we have for tools under Java 17 and what we open under Java 11.

For example this does not emit any warnings when we are on Java 17:
{code:java}
./tools/bin/auditlogviewer /tmp/diagnostics -f {code}
But it does emit these warnings when we are on Java 11
{code:java}
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access using Lookup on net.openhft.chronicle.core.Jvm (file:/tmp/apache-test/apache-cassandra-5.0-rc1-SNAPSHOT/lib/chronicle-core-2.23.36.jar) to class java.lang.reflect.AccessibleObject
WARNING: Please consider reporting this to the maintainers of net.openhft.chronicle.core.Jvm
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{code}
When I compared what that tool runs with on Java 17 and Java 11, I see this:

 

Java 17
{code:java}
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED 
--add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED 
--add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED 
--add-exports java.rmi/sun.rmi.server=ALL-UNNAMED 
--add-exports java.sql/java.sql=ALL-UNNAMED 
--add-exports java.base/java.lang.ref=ALL-UNNAMED 
--add-exports jdk.unsupported/sun.misc=ALL-UNNAMED 
--add-opens java.base/java.lang.module=ALL-UNNAMED 
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED 
--add-opens java.base/jdk.internal.ref=ALL-UNNAMED 
--add-opens java.base/jdk.internal.reflect=ALL-UNNAMED 
--add-opens java.base/jdk.internal.math=ALL-UNNAMED 
--add-opens java.base/jdk.internal.module=ALL-UNNAMED 
--add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED 
--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED 
--add-opens java.base/sun.nio.ch=ALL-UNNAMED 
--add-opens java.base/java.io=ALL-UNNAMED 
--add-opens java.base/java.lang=ALL-UNNAMED 
--add-opens java.base/java.lang.reflect=ALL-UNNAMED 
--add-opens java.base/java.util=ALL-UNNAMED 
--add-opens java.base/java.nio=ALL-UNNAMED 
--add-exports jdk.attach/sun.tools.attach=ALL-UNNAMED 
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED 
--add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED {code}
For Java 11
{code:java}
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED 
--add-exports java.base/jdk.internal.ref=ALL-UNNAMED 
--add-exports java.base/sun.nio.ch=ALL-UNNAMED 
--add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED 
--add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED 
--add-exports java.rmi/sun.rmi.server=ALL-UNNAMED 
--add-exports java.sql/java.sql=ALL-UNNAMED 
--add-opens java.base/java.lang.module=ALL-UNNAMED 
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED 
--add-opens java.base/jdk.internal.ref=ALL-UNNAMED 
--add-opens java.base/jdk.internal.reflect=ALL-UNNAMED 
--add-opens java.base/jdk.internal.math=ALL-UNNAMED 
--add-opens java.base/jdk.internal.module=ALL-UNNAMED 
--add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED 
--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED {code}
The difference is that we are not exporting this for Java 11
{code:java}
--add-opens java.base/sun.nio.ch=ALL-UNNAMED 
--add-opens java.base/java.io=ALL-UNNAMED 
--add-opens java.base/java.lang=ALL-UNNAMED 
--add-opens java.base/java.lang.reflect=ALL-UNNAMED 
--add-opens java.base/java.util=ALL-UNNAMED 
--add-opens java.base/java.nio=ALL-UNNAMED 
--add-opens java.base/java.lang.reflect=ALL-UNNAMED {code}
For Java 17, we explicitly add only these which are not applicable for 11 (check the end of tools/bin/cassandra.in.sh)
{code:java}
--add-exports jdk.attach/sun.tools.attach=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac=ALL-UNNAMED  {code}
 

So, what I propose is that we add the missing opens to cassandra.in.sh for Java 11.

Even better, I would add this to conf/jvm11-clients.options