Update Netty to Java 21
Closed this issue ยท 9 comments
just want ask this, any plan to do it and fix bug...
any plan to fix such as
java.lang.IllegalAccessException: class io.netty.util.internal.PlatformDependent0$6 cannot access class jdk.internal.misc.Unsafe (in module java.base) because module java.base does not export jdk.internal.misc to unnamed module @6767c1fc
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:394)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:714)
at java.base/java.lang.reflect.Method.invoke(Method.java:571)
at io.netty.util.internal.PlatformDependent0$6.run(PlatformDependent0.java:334)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:325)
at io.netty.util.internal.PlatformDependent.isAndroid(PlatformDependent.java:214)
at io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:82)
at io.netty.channel.nio.NioEventLoop.newTaskQueue(NioEventLoop.java:269)
at io.netty.util.concurrent.SingleThreadEventExecutor.<init>(SingleThreadEventExecutor.java:166)
at io.netty.channel.SingleThreadEventLoop.<init>(SingleThreadEventLoop.java:58)
at io.netty.channel.nio.NioEventLoop.<init>(NioEventLoop.java:135)
at io.netty.channel.nio.NioEventLoopGroup.newChild(NioEventLoopGroup.java:127)
at io.netty.channel.nio.NioEventLoopGroup.newChild(NioEventLoopGroup.java:36)
at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:84)
at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:58)
at io.netty.channel.MultithreadEventLoopGroup.<init>(MultithreadEventLoopGroup.java:52)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:87)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:82)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:63)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:51)
at com.bfxy.netty.marshalling.Server.main(Server.java:17)
because module java.base does not export jdk.internal.misc to unnamed module,
that so hated
please use JEP 442 for java 21. maybe we can create a new version for this special.
detail here https://openjdk.org/jeps/442
Whatever Netty version you're talking about is not the latest. And the stack trace you're showing is most likely from a DEBUG log line.
Whatever Netty version you're talking about is not the latest. And the stack trace you're showing is most likely from a DEBUG log line.
Originally posted by @chrisvest in #13975 (comment)
What mean?here version
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.108.Final</version>
</dependency>
when run on java 21, exception will be create. because java 21 not support access java.io.base or other internal package.
I think code in PlatformDependent0 is trying to detect. You can share the full log, it should contains information which printed in PlatformDependent0.java
<dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>4.1.108.Final</version> </dependency>
The mystery deepens.
According to your stack trace, PlatformDependent0.java
line 334 makes a call to the java.lang.reflect.Method.invoke()
method.
However, if we look at line 334 in the 4.1.108.Final tag, we just see a closing curly-bracket:
netty/common/src/main/java/io/netty/util/internal/PlatformDependent0.java
Lines 332 to 336 in 3a3f9d1
This means the version of netty-common
you have at runtime, is not the one implied by your netty-all
dependency.
Probably you have a mix of netty versions on your classpath at runtime, and this can cause all sorts of problems.
This is most likely the root cause of your troubles, and the stack trace you see is just a symptom.
I suggest you investigate your netty versions first, and only look at how well Java 21 is supported once you've made sure all your netty versions are coordinated.
Quick solution :import a netty bom in your parent pom, then fixed