Skip to content

How to run Aeron code with JDK 16 and JDK 17

Problem

JDK 16 changed the default access to the sun package to deny - it used to be a warning. When running Aeron code on JDK 16 you may get an error similar to the following:

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Set sun.nio.ch.SelectorImpl.selectedKeys accessible: module java.base does not "opens sun.nio.ch" to unnamed module @XXXXXX

Solution

Add --add-opens java.base/sun.nio.ch=ALL-UNNAMED or --illegal-access=permit (JDK 16 only) to the JVM arguments.

Discussion

JDK 16 - via JEP 396 - strongly encapsulates JDK internals used by Agrona's TransportPoller. To enable Aeron to run without error, you will need to permit access or explicitly open sun.nio.ch.

With JDK 17, --illegal-access=permit can no longer be used (see JEP 403), however, --add-opens java.base/sun.nio.ch=ALL-UNNAMED is expected to work.

See Also

Back to top