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

GraalVM native-image doesn't compile with Netty #11122

Closed
ScottPierce opened this issue Mar 28, 2021 · 13 comments
Closed

GraalVM native-image doesn't compile with Netty #11122

ScottPierce opened this issue Mar 28, 2021 · 13 comments
Labels
duplicate graal Issues related to running on GraalVM

Comments

@ScottPierce
Copy link

Expected behavior

Netty compiles with GraalVM native-image

Actual behavior

Compilation fails:

12:37:06.278 [ForkJoinPool-4-worker-27] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
12:37:06.681 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent - Platform: MacOS
12:37:06.682 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false
12:37:06.682 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent0 - Java version: 11
12:37:06.682 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
12:37:06.683 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
12:37:06.683 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
12:37:06.683 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent0 - direct buffer constructor: unavailable
java.lang.UnsupportedOperationException: Reflective setAccessible(true) disabled
        at io.netty.util.internal.ReflectionUtil.trySetAccessible(ReflectionUtil.java:31)
        at io.netty.util.internal.PlatformDependent0$4.run(PlatformDependent0.java:238)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:232)
        at io.netty.util.internal.PlatformDependent.isAndroid(PlatformDependent.java:294)
        at io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:93)
        at io.netty.util.ConstantPool.<init>(ConstantPool.java:32)
        at io.netty.channel.ChannelOption$1.<init>(ChannelOption.java:36)
        at io.netty.channel.ChannelOption.<clinit>(ChannelOption.java:36)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1042)
        at jdk.unsupported/sun.misc.Unsafe.ensureClassInitialized(Unsafe.java:698)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.ensureClassInitialized(ConfigurableClassInitialization.java:174)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.computeInitKindAndMaybeInitializeClass(ConfigurableClassInitialization.java:607)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.computeInitKindAndMaybeInitializeClass(ConfigurableClassInitialization.java:127)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.maybeInitializeHosted(ConfigurableClassInitialization.java:165)
        at com.oracle.svm.hosted.SVMHost.initializeType(SVMHost.java:265)
        at com.oracle.graal.pointsto.meta.AnalysisType.lambda$new$0(AnalysisType.java:227)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:64)
        at com.oracle.graal.pointsto.meta.AnalysisType.ensureInitialized(AnalysisType.java:600)
        at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:364)
        at com.oracle.graal.pointsto.infrastructure.AnalysisConstantPool.lookupField(AnalysisConstantPool.java:51)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.lookupField(BytecodeParser.java:4360)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4914)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5400)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3436)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3243)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1109)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1003)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84)
        at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:76)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:212)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
        at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:223)
        at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:357)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:313)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:302)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:103)
        at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultSpecialInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:368)
        at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:470)
        at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:542)
        at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:547)
        at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
12:37:06.889 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: unavailable true
java.lang.UnsupportedOperationException: Reflective setAccessible(true) disabled
        at io.netty.util.internal.ReflectionUtil.trySetAccessible(ReflectionUtil.java:31)
        at io.netty.util.internal.PlatformDependent0$5.run(PlatformDependent0.java:310)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:284)
        at io.netty.util.internal.PlatformDependent.isAndroid(PlatformDependent.java:294)
        at io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:93)
        at io.netty.util.ConstantPool.<init>(ConstantPool.java:32)
        at io.netty.channel.ChannelOption$1.<init>(ChannelOption.java:36)
        at io.netty.channel.ChannelOption.<clinit>(ChannelOption.java:36)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1042)
        at jdk.unsupported/sun.misc.Unsafe.ensureClassInitialized(Unsafe.java:698)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.ensureClassInitialized(ConfigurableClassInitialization.java:174)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.computeInitKindAndMaybeInitializeClass(ConfigurableClassInitialization.java:607)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.computeInitKindAndMaybeInitializeClass(ConfigurableClassInitialization.java:127)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.maybeInitializeHosted(ConfigurableClassInitialization.java:165)
        at com.oracle.svm.hosted.SVMHost.initializeType(SVMHost.java:265)
        at com.oracle.graal.pointsto.meta.AnalysisType.lambda$new$0(AnalysisType.java:227)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:64)
        at com.oracle.graal.pointsto.meta.AnalysisType.ensureInitialized(AnalysisType.java:600)
        at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:364)
        at com.oracle.graal.pointsto.infrastructure.AnalysisConstantPool.lookupField(AnalysisConstantPool.java:51)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.lookupField(BytecodeParser.java:4360)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4914)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5400)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3436)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3243)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1109)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1003)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84)
        at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:76)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:212)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
        at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:223)
        at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:357)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:313)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:302)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:103)
        at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultSpecialInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:368)
        at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:470)
        at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:542)
        at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:547)
        at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
12:37:06.935 [ForkJoinPool-2-worker-17] 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 @6a519f47
        at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
        at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:591)
        at java.base/java.lang.reflect.Method.invoke(Method.java:558)
        at io.netty.util.internal.PlatformDependent0$6.run(PlatformDependent0.java:352)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:343)
        at io.netty.util.internal.PlatformDependent.isAndroid(PlatformDependent.java:294)
        at io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:93)
        at io.netty.util.ConstantPool.<init>(ConstantPool.java:32)
        at io.netty.channel.ChannelOption$1.<init>(ChannelOption.java:36)
        at io.netty.channel.ChannelOption.<clinit>(ChannelOption.java:36)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1042)
        at jdk.unsupported/sun.misc.Unsafe.ensureClassInitialized(Unsafe.java:698)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.ensureClassInitialized(ConfigurableClassInitialization.java:174)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.computeInitKindAndMaybeInitializeClass(ConfigurableClassInitialization.java:607)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.computeInitKindAndMaybeInitializeClass(ConfigurableClassInitialization.java:127)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.maybeInitializeHosted(ConfigurableClassInitialization.java:165)
        at com.oracle.svm.hosted.SVMHost.initializeType(SVMHost.java:265)
        at com.oracle.graal.pointsto.meta.AnalysisType.lambda$new$0(AnalysisType.java:227)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:64)
        at com.oracle.graal.pointsto.meta.AnalysisType.ensureInitialized(AnalysisType.java:600)
        at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:364)
        at com.oracle.graal.pointsto.infrastructure.AnalysisConstantPool.lookupField(AnalysisConstantPool.java:51)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.lookupField(BytecodeParser.java:4360)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4914)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5400)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3436)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3243)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1109)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1003)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84)
        at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:76)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:212)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
        at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:223)
        at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:357)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:313)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:302)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:103)
        at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultSpecialInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:368)
        at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:470)
        at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:542)
        at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:547)
        at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
12:37:07.008 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): unavailable
12:37:07.008 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
12:37:07.011 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent - maxDirectMemory: 6681526272 bytes (maybe)
12:37:07.013 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: /var/folders/5h/wqw3wlf50m7_c5tm89ldzqb00000gp/T (java.io.tmpdir)
12:37:07.029 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
12:37:07.029 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: -1 bytes
12:37:07.029 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1
12:37:07.030 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.CleanerJava9 - java.nio.ByteBuffer.cleaner(): available
12:37:07.030 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
12:37:07.779 [ForkJoinPool-2-worker-9] DEBUG io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.workdir: /var/folders/5h/wqw3wlf50m7_c5tm89ldzqb00000gp/T (io.netty.tmpdir)
12:37:07.779 [ForkJoinPool-2-worker-9] DEBUG io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.deleteLibAfterLoading: true
12:37:07.779 [ForkJoinPool-2-worker-9] DEBUG io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.tryPatchShadedId: true
12:37:07.864 [ForkJoinPool-2-worker-9] DEBUG io.netty.util.internal.NativeLibraryLoader - Successfully loaded the library /var/folders/5h/wqw3wlf50m7_c5tm89ldzqb00000gp/T/libnetty_transport_native_kqueue_x86_6411448581691456785935.dylib
12:37:07.865 [ForkJoinPool-2-worker-9] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false
12:37:07.865 [ForkJoinPool-2-worker-9] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false
12:37:07.867 [ForkJoinPool-2-worker-9] DEBUG io.netty.util.NetUtilInitializations - Loopback interface: lo0 (lo0, 0:0:0:0:0:0:0:1%lo0)
12:37:07.867 [ForkJoinPool-2-worker-9] DEBUG io.netty.util.NetUtil - Failed to get SOMAXCONN from sysctl and file /proc/sys/net/core/somaxconn. Default: 128
12:37:07.869 [ForkJoinPool-2-worker-9] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 24
12:37:08.374 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024
12:37:08.375 [ForkJoinPool-2-worker-17] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096
Warning: class initialization of class io.netty.handler.ssl.ReferenceCountedOpenSslContext failed with exception java.lang.NoClassDefFoundError: io/netty/internal/tcnative/SSLPrivateKeyMethod. This class will be initialized at run time because option --allow-incomplete-classpath is used for image building. Use the option --initialize-at-run-time=io.netty.handler.ssl.ReferenceCountedOpenSslContext to explicitly request delayed initialization of this class.
12:37:08.674 [ForkJoinPool-2-worker-27] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
12:37:08.675 [ForkJoinPool-2-worker-27] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
12:37:08.738 [ForkJoinPool-2-worker-25] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.processId: 35880 (auto-detected)
12:37:08.742 [ForkJoinPool-2-worker-25] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.machineId: ac:de:48:ff:fe:00:11:22 (auto-detected)
12:37:08.758 [ForkJoinPool-2-worker-19] DEBUG io.netty.handler.ssl.JdkSslContext - Default protocols (JDK): [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1] 
12:37:08.759 [ForkJoinPool-2-worker-19] DEBUG io.netty.handler.ssl.JdkSslContext - Default cipher suites (JDK): [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384]
12:37:08.763 [ForkJoinPool-2-worker-25] DEBUG io.netty.handler.ssl.OpenSsl - netty-tcnative not in the classpath; OpenSslEngine will be unavailable.
12:37:08.932 [ForkJoinPool-4-worker-27] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple
12:37:08.932 [ForkJoinPool-4-worker-27] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.targetRecords: 4
Warning: class initialization of class io.netty.channel.epoll.EpollEventArray failed with exception java.lang.NoClassDefFoundError: Could not initialize class io.netty.channel.epoll.Native. This class will be initialized at run time because option --allow-incomplete-classpath is used for image building. Use the option --initialize-at-run-time=io.netty.channel.epoll.EpollEventArray to explicitly request delayed initialization of this class.
Warning: class initialization of class io.netty.channel.epoll.Native failed with exception java.lang.NoClassDefFoundError: Could not initialize class io.netty.channel.epoll.Native. This class will be initialized at run time because option --allow-incomplete-classpath is used for image building. Use the option --initialize-at-run-time=io.netty.channel.epoll.Native to explicitly request delayed initialization of this class.
12:37:09.139 [ForkJoinPool-2-worker-7] DEBUG io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available
Warning: class initialization of class io.netty.handler.ssl.JdkNpnApplicationProtocolNegotiator failed with exception java.lang.NoClassDefFoundError: org/eclipse/jetty/npn/NextProtoNego$Provider. This class will be initialized at run time because option --allow-incomplete-classpath is used for image building. Use the option --initialize-at-run-time=io.netty.handler.ssl.JdkNpnApplicationProtocolNegotiator to explicitly request delayed initialization of this class.
12:37:10.202 [ForkJoinPool-2-worker-23] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxCapacityPerThread: 4096
12:37:10.202 [ForkJoinPool-2-worker-23] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxSharedCapacityFactor: 2
12:37:10.202 [ForkJoinPool-2-worker-23] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.linkCapacity: 16
12:37:10.202 [ForkJoinPool-2-worker-23] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.ratio: 8
12:37:10.202 [ForkJoinPool-2-worker-23] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.delayedQueue.ratio: 8
12:37:10.241 [ForkJoinPool-4-worker-23] DEBUG io.netty.buffer.AbstractByteBuf - -Dio.netty.buffer.checkAccessible: true
12:37:10.242 [ForkJoinPool-4-worker-23] DEBUG io.netty.buffer.AbstractByteBuf - -Dio.netty.buffer.checkBounds: true
12:37:10.242 [ForkJoinPool-4-worker-23] DEBUG io.netty.util.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector@6f157444
To see how the classes got initialized, use --trace-class-initialization=io.netty.util.AbstractReferenceCounted
[social-media-api:35880]     analysis:  10,618.41 ms,  2.30 GB
Error: Classes that should be initialized at run time got initialized during image building:
 io.netty.util.AbstractReferenceCounted the class was requested to be initialized at run time (from the command line). To see why io.netty.util.AbstractReferenceCounted got initialized use --trace-class-initialization=io.netty.util.AbstractReferenceCounted

com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
 io.netty.util.AbstractReferenceCounted the class was requested to be initialized at run time (from the command line). To see why io.netty.util.AbstractReferenceCounted got initialized use --trace-class-initialization=io.netty.util.AbstractReferenceCounted

        at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:539)
        at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:226)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:740)
        at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:70)
        at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:740)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:563)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:476)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Error: Image build request failed with exit status 1

Steps to reproduce

Run

./gradlew clean :social-media-server:shadowJar && native-image -cp social-media-server/build/libs/social-media-server-all.jar 

Minimal yet complete reproducer code (or URL to code)

Here is a gradle project to reproduce it:
social-media.zip

Netty version

io.netty:netty-all:4.1.60.Final

JVM version (e.g. java -version)

java -version
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment GraalVM CE 21.0.0.2 (build 11.0.10+8-jvmci-21.0-b06)
OpenJDK 64-Bit Server VM GraalVM CE 21.0.0.2 (build 11.0.10+8-jvmci-21.0-b06, mixed mode, sharing)

OS version (e.g. uname -a)

OSX

uname -a
Darwin Scott-Pierce 19.6.0 Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64 x86_64
@ScottPierce ScottPierce changed the title Doesn't work with GraalVM GraalVM native-image doesn't compile with Netty Mar 28, 2021
@normanmaurer
Copy link
Member

PRs welcome... Sorry I don't have much experience with graal at all.

@skyguard1
Copy link
Contributor

skyguard1 commented Apr 1, 2021

In netty java11 the setAccessible operation is disabled, you can change to java8 and below, or add the
-Dio.netty.tryReflectionSetAccessible=true parameter to allow netty to use the setAccessible operation

@ninja-
Copy link

ninja- commented Apr 5, 2021

hmm I thought we had integration tests with GraalVM....as incompatibilites pile up with netty development it would get harder and harder to fix after time ;)

@skyguard1 there are several crashes in this log while most are non-critical. I think setAccessible is non critical in this case.
The critical one is AbstractReferenceCounted loaded at runtime.
Best start would be to follow the instructions from logs and trace loaded classes

io.netty.util.AbstractReferenceCounted the class was requested to be initialized at run time (from the command line). To see why io.netty.util.AbstractReferenceCounted got initialized use --trace-class-initialization=io.netty.util.AbstractReferenceCounted

and then possible adjust native-image.properties
(which can be extremely tricky for larger projects and is usually hit or miss)

@chrisvest
Copy link
Contributor

@ScottPierce I'm not so familiar with Gradle builds. Can you try out adding the suggested command line argument and post the resulting output?

--trace-class-initialization=io.netty.util.AbstractReferenceCounted

The AbstractReferenceCounted is used in many places, so it's not easy to figure out where it's being pulled into the image from just reading the code.

@chrisvest
Copy link
Contributor

Sounds related to #10616

@chrisvest
Copy link
Contributor

Yeah, this is a duplicate of #10616. Closing this one.

Epoll is initialising classes from JNI code, hence it's not easy to get an accurate trace of what needs to be loaded.

You can work around it by initialising all of unix, epoll, etc. packages at runtime:

--initialize-at-run-time=io.netty.handler.ssl.util.ThreadLocalInsecureRandom,io.netty.channel.unix,io.netty.channel.epoll,io.netty.channel.kqueue

Or you can switch to using the NIO transport.

@chrisvest chrisvest added the graal Issues related to running on GraalVM label Apr 12, 2021
@jvican
Copy link

jvican commented Jun 9, 2021

@chrisvest The folks over at the quarkus project seem to be able to get away without initializing those whole packages at runtime. Instead, they just whitelist some classes that should be run there. I've tried in my big vertx-based application whether this approach works and it does. See https://github.com/quarkusio/quarkus/blob/main/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java for some more context in case you are not familiar with what they are doing. Maybe we can just implement the whole thing natively in the netty project?

@chrisvest
Copy link
Contributor

@jvican We don't have much graal expertise, so any help with that would be greatly appreciated. Do you want to open a PR?

@jvican
Copy link

jvican commented Jul 6, 2021

I hope to be able to dig some time to help out @chrisvest. It'd be ideal if the GraalVM team actually gave us better direction in how we could set up Netty with GraalVM Native to work effectively, perhaps working hand-to-hand with us for a few weeks. Another fruitful collaboration would be to engage with the Quarkus team. I might open a ticket in their repository to try to build more alignment.

@jvican
Copy link

jvican commented Jul 6, 2021

By the way, do keep us posted on the work you're doing to add epoll native support. I'll borrow whatever configuration you put together and can help test it in production. The JNI configuration is the hardest to get right.

@chrisvest
Copy link
Contributor

@jvican I was working on this back in April: #11163 - it stalled back then because I couldn't get the build to pass. You're welcome to pick it up and see if you can make it work. The trouble is that interactions with JNI seems to hide the cause of some Graal native image build failures.

chrisvest added a commit to chrisvest/netty that referenced this issue Nov 29, 2021
Motivation:
People expect Netty to just be Netty when building native images, and so try to use the epoll transport.

Modification:
Add a native-image.properties file that tells native-image to initialise all of the epoll classes at runtime.

Result:
We can now use epoll in native runtime images.

Fixes netty#11122 netty#10616 netty#9918
@weitingyuk
Copy link

@ScottPierce ScottPierce, have you solved this issue, i have the same error when use graalvm

@ScottPierce
Copy link
Author

ScottPierce commented Dec 8, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate graal Issues related to running on GraalVM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants