Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(jdk17.0.4)Could not initialize class io.netty.util.internal.PlatformDependent0 #12737

Closed
liyouxina opened this issue Aug 25, 2022 · 13 comments
Closed

Comments

@liyouxina
Copy link

liyouxina commented Aug 25, 2022

Expected behavior

same code works with jdk8

Actual behavior

Caused by: java.lang.NoClassDefFoundError: Could not initialize class io.netty.util.internal.PlatformDependent0
at io.netty.util.internal.PlatformDependent.getSystemClassLoader(PlatformDependent.java:694)
at io.netty.channel.nio.NioEventLoop$4.run(NioEventLoop.java:171)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:167)
at io.netty.channel.nio.NioEventLoop.(NioEventLoop.java:149)
at io.netty.channel.nio.NioEventLoopGroup.newChild(NioEventLoopGroup.java:102)
at io.netty.util.concurrent.MultithreadEventExecutorGroup.(MultithreadEventExecutorGroup.java:64)
at io.netty.channel.MultithreadEventLoopGroup.(MultithreadEventLoopGroup.java:49)
at io.netty.channel.nio.NioEventLoopGroup.(NioEventLoopGroup.java:70)
at io.netty.channel.nio.NioEventLoopGroup.(NioEventLoopGroup.java:65)
at io.netty.channel.nio.NioEventLoopGroup.(NioEventLoopGroup.java:56)

Steps to reproduce

Minimal yet complete reproducer code (or URL to code)

Netty version

4.1.75.Final

JVM version (e.g. java -version)

jdk17.0.4

OS version (e.g. uname -a)

alios7.x86_64 #1 SMP Mon Jan 25 10:47:38 CST 2021 x86_64 x86_64 x86_64 GNU/Linux (some hidden)

@liyouxina liyouxina changed the title Could not initialize class io.netty.util.internal.PlatformDependent0 (jdk17.0.4)Could not initialize class io.netty.util.internal.PlatformDependent0 Aug 25, 2022
@chrisvest
Copy link
Contributor

Please show the whole stack trace.

@liyouxina
Copy link
Author

Please show the whole stack trace.

no java.lang.ExceptionInInitializerError

@yoa1226
Copy link
Contributor

yoa1226 commented Aug 26, 2022

@liyouxina how to reproduce? can produces this exception when I run the io.netty.example.echo.EchoServer in the netty-example module?

@liyouxina
Copy link
Author

liyouxina commented Aug 31, 2022

problem solved !!
I fix it by adding this to JVM args
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens jdk.unsupported/sun.misc=ALL-UNNAMED --add-opens java.base/sun.security.action=ALL-UNNAMED --add-opens jdk.naming.rmi/com.sun.jndi.rmi.registry=ALL-UNNAMED --add-opens java.base/sun.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED

these args may have other that is not related to this problem, but I can not pick them out

@liyouxina
Copy link
Author

@liyouxina how to reproduce? can produces this exception when I run the io.netty.example.echo.EchoServer in the netty-example module?

use rocketmq and jdk17, probably you can reproduce this

@liyouxina
Copy link
Author

add -Dsun.reflect.debugModuleAccessChecks=access to JVM args and run your application
you will know how to fix this problem

@chrisvest
Copy link
Contributor

We run builds with Java 17, so this doesn't make much sense.

Also, both PlatformDependent and PlatformDependent0 are in the same package, same module, same jar file, so why can one be found but not the other?

@tdvous
Copy link

tdvous commented May 10, 2023

Do we have plan to get rid of these unsupported/removed APIs instead of --add-opens workaround?

@chrisvest
Copy link
Contributor

@tdvous They only opportunistically enable optimizations. Netty can run without them just fine.

@Talbot3
Copy link

Talbot3 commented Apr 13, 2024

i hope change it that don't use java interal package,please. because java 21 also have this question.

@Talbot3
Copy link

Talbot3 commented Apr 13, 2024

just like this

/Users/lilisi/.sdkman/candidates/java/21.0.2-zulu/zulu-21.jdk/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=59724:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /Users/lilisi/JavaProj/Architect-Stage-Java/Architect-Stage-Netty/netty-001/target/classes:/Users/lilisi/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.1.5.RELEASE/spring-boot-starter-web-2.1.5.RELEASE.jar:/Users/lilisi/.m2/repository/org/springframework/boot/spring-boot-starter/2.1.5.RELEASE/spring-boot-starter-2.1.5.RELEASE.jar:/Users/lilisi/.m2/repository/org/springframework/boot/spring-boot/2.1.5.RELEASE/spring-boot-2.1.5.RELEASE.jar:/Users/lilisi/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.1.5.RELEASE/spring-boot-autoconfigure-2.1.5.RELEASE.jar:/Users/lilisi/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.1.5.RELEASE/spring-boot-starter-logging-2.1.5.RELEASE.jar:/Users/lilisi/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/Users/lilisi/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/Users/lilisi/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.11.2/log4j-to-slf4j-2.11.2.jar:/Users/lilisi/.m2/repository/org/apache/logging/log4j/log4j-api/2.11.2/log4j-api-2.11.2.jar:/Users/lilisi/.m2/repository/org/slf4j/jul-to-slf4j/1.7.26/jul-to-slf4j-1.7.26.jar:/Users/lilisi/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/Users/lilisi/.m2/repository/org/yaml/snakeyaml/1.23/snakeyaml-1.23.jar:/Users/lilisi/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.1.5.RELEASE/spring-boot-starter-json-2.1.5.RELEASE.jar:/Users/lilisi/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.8/jackson-databind-2.9.8.jar:/Users/lilisi/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/Users/lilisi/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.8/jackson-core-2.9.8.jar:/Users/lilisi/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.8/jackson-datatype-jdk8-2.9.8.jar:/Users/lilisi/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.8/jackson-datatype-jsr310-2.9.8.jar:/Users/lilisi/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.8/jackson-module-parameter-names-2.9.8.jar:/Users/lilisi/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.1.5.RELEASE/spring-boot-starter-tomcat-2.1.5.RELEASE.jar:/Users/lilisi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.19/tomcat-embed-core-9.0.19.jar:/Users/lilisi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.19/tomcat-embed-el-9.0.19.jar:/Users/lilisi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.19/tomcat-embed-websocket-9.0.19.jar:/Users/lilisi/.m2/repository/org/hibernate/validator/hibernate-validator/6.0.16.Final/hibernate-validator-6.0.16.Final.jar:/Users/lilisi/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/Users/lilisi/.m2/repository/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/Users/lilisi/.m2/repository/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar:/Users/lilisi/.m2/repository/org/springframework/spring-web/5.1.7.RELEASE/spring-web-5.1.7.RELEASE.jar:/Users/lilisi/.m2/repository/org/springframework/spring-beans/5.1.7.RELEASE/spring-beans-5.1.7.RELEASE.jar:/Users/lilisi/.m2/repository/org/springframework/spring-webmvc/5.1.7.RELEASE/spring-webmvc-5.1.7.RELEASE.jar:/Users/lilisi/.m2/repository/org/springframework/spring-aop/5.1.7.RELEASE/spring-aop-5.1.7.RELEASE.jar:/Users/lilisi/.m2/repository/org/springframework/spring-context/5.1.7.RELEASE/spring-context-5.1.7.RELEASE.jar:/Users/lilisi/.m2/repository/org/springframework/spring-expression/5.1.7.RELEASE/spring-expression-5.1.7.RELEASE.jar:/Users/lilisi/.m2/repository/org/slf4j/slf4j-api/1.7.26/slf4j-api-1.7.26.jar:/Users/lilisi/.m2/repository/org/springframework/spring-core/5.1.7.RELEASE/spring-core-5.1.7.RELEASE.jar:/Users/lilisi/.m2/repository/org/springframework/spring-jcl/5.1.7.RELEASE/spring-jcl-5.1.7.RELEASE.jar:/Users/lilisi/.m2/repository/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar:/Users/lilisi/.m2/repository/io/netty/netty-all/4.1.108.Final/netty-all-4.1.108.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-buffer/4.1.36.Final/netty-buffer-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec/4.1.36.Final/netty-codec-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec-dns/4.1.36.Final/netty-codec-dns-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec-haproxy/4.1.36.Final/netty-codec-haproxy-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec-http/4.1.36.Final/netty-codec-http-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec-http2/4.1.36.Final/netty-codec-http2-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec-memcache/4.1.36.Final/netty-codec-memcache-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec-mqtt/4.1.36.Final/netty-codec-mqtt-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec-redis/4.1.36.Final/netty-codec-redis-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec-smtp/4.1.36.Final/netty-codec-smtp-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec-socks/4.1.36.Final/netty-codec-socks-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec-stomp/4.1.36.Final/netty-codec-stomp-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-codec-xml/4.1.36.Final/netty-codec-xml-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-common/4.1.36.Final/netty-common-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-handler/4.1.36.Final/netty-handler-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport-native-unix-common/4.1.36.Final/netty-transport-native-unix-common-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-handler-proxy/4.1.36.Final/netty-handler-proxy-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-handler-ssl-ocsp/4.1.108.Final/netty-handler-ssl-ocsp-4.1.108.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-resolver/4.1.36.Final/netty-resolver-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-resolver-dns/4.1.36.Final/netty-resolver-dns-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport/4.1.36.Final/netty-transport-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport-rxtx/4.1.36.Final/netty-transport-rxtx-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport-sctp/4.1.36.Final/netty-transport-sctp-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport-udt/4.1.36.Final/netty-transport-udt-4.1.36.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport-classes-epoll/4.1.108.Final/netty-transport-classes-epoll-4.1.108.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport-classes-kqueue/4.1.108.Final/netty-transport-classes-kqueue-4.1.108.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-resolver-dns-classes-macos/4.1.108.Final/netty-resolver-dns-classes-macos-4.1.108.Final.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport-native-epoll/4.1.36.Final/netty-transport-native-epoll-4.1.36.Final-linux-x86_64.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport-native-epoll/4.1.108.Final/netty-transport-native-epoll-4.1.108.Final-linux-aarch_64.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport-native-epoll/4.1.108.Final/netty-transport-native-epoll-4.1.108.Final-linux-riscv64.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport-native-kqueue/4.1.36.Final/netty-transport-native-kqueue-4.1.36.Final-osx-x86_64.jar:/Users/lilisi/.m2/repository/io/netty/netty-transport-native-kqueue/4.1.108.Final/netty-transport-native-kqueue-4.1.108.Final-osx-aarch_64.jar:/Users/lilisi/.m2/repository/io/netty/netty-resolver-dns-native-macos/4.1.108.Final/netty-resolver-dns-native-macos-4.1.108.Final-osx-x86_64.jar:/Users/lilisi/.m2/repository/io/netty/netty-resolver-dns-native-macos/4.1.108.Final/netty-resolver-dns-native-macos-4.1.108.Final-osx-aarch_64.jar:/Users/lilisi/.m2/repository/com/google/guava/guava/25.1-jre/guava-25.1-jre.jar:/Users/lilisi/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/Users/lilisi/.m2/repository/org/checkerframework/checker-qual/2.0.0/checker-qual-2.0.0.jar:/Users/lilisi/.m2/repository/com/google/errorprone/error_prone_annotations/2.1.3/error_prone_annotations-2.1.3.jar:/Users/lilisi/.m2/repository/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar:/Users/lilisi/.m2/repository/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar:/Users/lilisi/.m2/repository/com/google/protobuf/protobuf-java/3.7.1/protobuf-java-3.7.1.jar:/Users/lilisi/.m2/repository/org/jboss/marshalling/jboss-marshalling/1.3.0.CR9/jboss-marshalling-1.3.0.CR9.jar:/Users/lilisi/.m2/repository/org/jboss/marshalling/jboss-marshalling-serial/2.1.4.Final/jboss-marshalling-serial-2.1.4.Final.jar:/Users/lilisi/.m2/repository/com/alibaba/fastjson/1.2.60/fastjson-1.2.60.jar com.bfxy.netty.marshalling.Client --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens jdk.unsupported/sun.misc=ALL-UNNAMED --add-opens java.base/sun.security.action=ALL-UNNAMED --add-opens jdk.naming.rmi/com.sun.jndi.rmi.registry=ALL-UNNAMED --add-opens java.base/sun.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED 20:09:46.159 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework 20:09:46.167 [main] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 16 20:09:46.190 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024 20:09:46.191 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096 20:09:46.205 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false 20:09:46.205 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512 20:09:46.228 [main] DEBUG io.netty.util.internal.PlatformDependent - Platform: MacOS 20:09:46.230 [main] DEBUG io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false 20:09:46.230 [main] DEBUG io.netty.util.internal.PlatformDependent0 - Java version: 21 20:09:46.233 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available 20:09:46.234 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available 20:09:46.235 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available 20:09:46.242 [main] DEBUG io.netty.util.internal.PlatformDependent0 - direct buffer constructor: unavailable java.lang.NoSuchMethodException: java.nio.DirectByteBuffer.<init>(long,int) at java.base/java.lang.Class.getConstructor0(Class.java:3761) at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2930) at io.netty.util.internal.PlatformDependent0$4.run(PlatformDependent0.java:223) at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:218) 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 io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:43) at com.bfxy.netty.marshalling.Client.main(Client.java:21) 20:09:46.242 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true 20:09:46.244 [main] DEBUG io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable 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 io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:43) at com.bfxy.netty.marshalling.Client.main(Client.java:21) 20:09:46.244 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): unavailable 20:09:46.244 [main] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available 20:09:46.261 [main] DEBUG io.netty.util.internal.PlatformDependent - maxDirectMemory: 4294967296 bytes (maybe) 20:09:46.262 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: /var/folders/b9/lvc6tzmx7gv33bpcfkfyqgm40000gn/T (java.io.tmpdir) 20:09:46.262 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model) 20:09:46.265 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: -1 bytes 20:09:46.265 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1 20:09:46.268 [main] DEBUG io.netty.util.internal.CleanerJava9 - java.nio.ByteBuffer.cleaner(): available 20:09:46.268 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false 20:09:46.275 [main] DEBUG io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available 20:09:46.526 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.processId: 64063 (auto-detected) 20:09:46.529 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false 20:09:46.529 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false 20:09:46.537 [main] DEBUG io.netty.util.NetUtil - Loopback interface: lo0 (lo0, 0:0:0:0:0:0:0:1%lo0) 20:09:46.538 [main] DEBUG io.netty.util.NetUtil - Failed to get SOMAXCONN from sysctl and file /proc/sys/net/core/somaxconn. Default: 128 20:09:46.542 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.machineId: a0:78:17:ff:fe:87:c3:c4 (auto-detected) 20:09:46.551 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple 20:09:46.552 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.targetRecords: 4 20:09:46.581 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 16 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 16 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimIntervalMillis: 0 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.useCacheForAllThreads: true 20:09:46.582 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedByteBuffersPerChunk: 1023 20:09:46.587 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled 20:09:46.587 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0 20:09:46.588 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384 20:09:46.646 [nioEventLoopGroup-2-1] WARN io.netty.channel.ChannelInitializer - Failed to initialize a channel. Closing: [id: 0x9dad53fc] java.lang.ExceptionInInitializerError: null at com.bfxy.netty.marshalling.MarshallingCodeCFactory.buildMarshallingDecoder(MarshallingCodeCFactory.java:22) at com.bfxy.netty.marshalling.Client$1.initChannel(Client.java:29) at com.bfxy.netty.marshalling.Client$1.initChannel(Client.java:26) at io.netty.channel.ChannelInitializer.initChannel(ChannelInitializer.java:129) at io.netty.channel.ChannelInitializer.handlerAdded(ChannelInitializer.java:112) at io.netty.channel.AbstractChannelHandlerContext.callHandlerAdded(AbstractChannelHandlerContext.java:964) at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:610) at io.netty.channel.DefaultChannelPipeline.access$100(DefaultChannelPipeline.java:46) at io.netty.channel.DefaultChannelPipeline$PendingHandlerAddedTask.execute(DefaultChannelPipeline.java:1461) at io.netty.channel.DefaultChannelPipeline.callHandlerAddedForAllHandlers(DefaultChannelPipeline.java:1126) at io.netty.channel.DefaultChannelPipeline.invokeHandlerAddedIfNeeded(DefaultChannelPipeline.java:651) at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:515) at io.netty.channel.AbstractChannel$AbstractUnsafe.access$200(AbstractChannel.java:428) at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:487) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:405) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:1583) Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make java.io.OptionalDataException(boolean) accessible: module java.base does not "opens java.io" to unnamed module @6767c1fc at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315) at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:194) at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:187) at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction$1.run(Marshalling.java:390) at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction$1.run(Marshalling.java:386) at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction.<init>(Marshalling.java:386) at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction.<init>(Marshalling.java:381) at org.jboss.marshalling.Marshalling.<clinit>(Marshalling.java:379) ... 21 common frames omitted Exception in thread "main" io.netty.channel.ExtendedClosedChannelException at io.netty.channel.AbstractChannel$AbstractUnsafe.ensureOpen(...)(Unknown Source)

@Talbot3
Copy link

Talbot3 commented Apr 13, 2024

Oracle has discouraged the use of Unsafe and other similar low-level APIs because they can lead to security vulnerabilities and other issues.

Starting with Java 9, Oracle began deprecating the use of Unsafe and planned to remove it in a future release. However, as of Java 17, Unsafe is still present but officially marked as deprecated. This means that Oracle recommends avoiding its use and finding alternative ways to achieve the same functionality without the associated risks.

It’s important to note that the future inclusion of Unsafe in the Java standard library is not guaranteed, and it may be removed in a future release. Therefore, if you are writing new code, you should avoid using Unsafe and look for safer alternatives. If you are maintaining existing code that uses Unsafe, you should consider migrating to a safer approach as soon as possible.

@Talbot3
Copy link

Talbot3 commented Apr 13, 2024

please use JEP 442 for java 21. maybe we can create a new version for this special.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants