document how to run on recent Java versions
We've recently seen a couple of questions around running Pekko with recent versions of Java.
Even though Pekko does use sun.misc.Unsafe in some places, Pekko can be used on Java 21 and such just fine as long as you pass the relevant JDK flags.
We should probably add a section to the documentation about that (or at least I couldn't find it)
We are adding something like these below when running real application in production:
SERVICE_OPTS="${SERVICE_OPTS} --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-exports java.base/sun.util.calendar=ALL-UNNAMED --add-exports java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/sun.net.util=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/sun.security.action=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens java.sql/java.sql=ALL-UNNAMED --add-opens java.base/java.util.regex=ALL-UNNAMED --add-opens jdk.unsupported/sun.misc=ALL-UNNAMED"
Not totally related with pekko.
@He-Pin do you mean we need to add the above --add-opens & --add-exports in our play application to make it run in Java 21 ?
I think Java 23+ users will need to add this to their java commands that used to run Pekko.
--sun-misc-unsafe-memory-access=allow
So far, this just silences a warning. In future Java versions this might be needed to allow sun.misc.Unsafe to be used at all.
Warnings look like
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
...
WARNING: sun.misc.Unsafe::allocateMemory will be removed in a future release