-
Notifications
You must be signed in to change notification settings - Fork 874
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
JAVA-2940: Add GraalVM native image build configurations #1560
Conversation
@@ -0,0 +1,214 @@ | |||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contents of this file largely taken from https://github.com/absurdfarce/graal-cassandra-driver/blob/master/reflection.json
core/src/main/resources/META-INF/native-image/com.datastax.oss/java-driver-core/reflection.json
Show resolved
Hide resolved
"allPublicConstructors": true, | ||
"allDeclaredMethods": true, | ||
"allPublicMethods": true | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"fields": [ | ||
{"name": "consumerIndex", "allowUnsafeAccess": true} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shaded jctools config from an actual Netty issue (netty/netty#10376)
...in/resources/META-INF/native-image/com.datastax.oss/java-driver-core/native-image.properties
Outdated
Show resolved
Hide resolved
"methods": [ | ||
{ "name": "<init>", "parameterTypes": [] } | ||
] | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this exclusion:
Exception in thread "main" java.lang.IllegalArgumentException: Class NioSocketChannel does not have a public non-arg constructor
at io.netty.channel.ReflectiveChannelFactory.<init>(ReflectiveChannelFactory.java:36)
at io.netty.bootstrap.AbstractBootstrap.channel(AbstractBootstrap.java:110)
at com.datastax.oss.driver.internal.core.channel.ChannelFactory.connect(ChannelFactory.java:192)
at com.datastax.oss.driver.internal.core.channel.ChannelFactory.connect(ChannelFactory.java:167)
at com.datastax.oss.driver.internal.core.channel.ChannelFactory.connect(ChannelFactory.java:148)
at com.datastax.oss.driver.internal.core.control.ControlConnection$SingleThreaded.connect(ControlConnection.java:363)
at com.datastax.oss.driver.internal.core.control.ControlConnection$SingleThreaded.init(ControlConnection.java:303)
at com.datastax.oss.driver.internal.core.control.ControlConnection$SingleThreaded.access$1100(ControlConnection.java:243)
at com.datastax.oss.driver.internal.core.control.ControlConnection.lambda$init$0(ControlConnection.java:122)
at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)
at io.netty.util.concurrent.PromiseTask.run(PromiseTask.java:106)
at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.NoSuchMethodException: io.netty.channel.socket.nio.NioSocketChannel.<init>()
at java.lang.Class.getConstructor0(DynamicHub.java:3082)
at java.lang.Class.getConstructor(DynamicHub.java:1825)
at io.netty.channel.ReflectiveChannelFactory.<init>(ReflectiveChannelFactory.java:34)
... 17 more
Not abundantly clear why this would be; NioSocketChannel very definitely does have a no-arg constructor. It's possible there's another Graal substitution at play here, although if that's the case I haven't been able to identify where it lives.
Note that Helidon had to address something similar: see helidon-io/helidon#1722
"methods": [ | ||
{ "name": "toLeakAwareBuffer", "parameterTypes": ["io.netty.buffer.ByteBuf"] } | ||
] | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this exclusion:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:315)
at java.lang.Class.ensureInitialized(DynamicHub.java:553)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:260)
at io.netty.buffer.ByteBufUtil.<clinit>(ByteBufUtil.java:86)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
at io.netty.buffer.ByteBufAllocator.<clinit>(ByteBufAllocator.java:24)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
at com.datastax.oss.driver.internal.core.context.DefaultNettyOptions.allocator(DefaultNettyOptions.java:144)
at com.datastax.oss.driver.internal.core.channel.ChannelFactory.connect(ChannelFactory.java:193)
at com.datastax.oss.driver.internal.core.channel.ChannelFactory.connect(ChannelFactory.java:167)
at com.datastax.oss.driver.internal.core.channel.ChannelFactory.connect(ChannelFactory.java:148)
at com.datastax.oss.driver.internal.core.control.ControlConnection$SingleThreaded.connect(ControlConnection.java:363)
at com.datastax.oss.driver.internal.core.control.ControlConnection$SingleThreaded.init(ControlConnection.java:303)
at com.datastax.oss.driver.internal.core.control.ControlConnection$SingleThreaded.access$1100(ControlConnection.java:243)
at com.datastax.oss.driver.internal.core.control.ControlConnection.lambda$init$0(ControlConnection.java:122)
at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)
at io.netty.util.concurrent.PromiseTask.run(PromiseTask.java:106)
at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.IllegalArgumentException: Can't find '[toLeakAwareBuffer]' in io.netty.buffer.AbstractByteBufAllocator
at io.netty.util.ResourceLeakDetector.addExclusions(ResourceLeakDetector.java:576)
at io.netty.buffer.AbstractByteBufAllocator.<clinit>(AbstractByteBufAllocator.java:36)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
... 25 more
Haven't dug into this one much to see if there's anything we can do here.
"methods": [ | ||
{ "name": "touch", "parameterTypes": ["java.lang.Object", "java.lang.Object"] } | ||
] | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this exclusion:
WARNING: An exception was thrown by com.datastax.oss.driver.internal.core.channel.ConnectInitHandler$$Lambda$df350d7c55c0f44e72fb6470156ed35696eba329.operationComplete() [3/1826]
java.lang.ExceptionInInitializerError
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:315)
at io.netty.channel.DefaultChannelPipeline.touch(DefaultChannelPipeline.java:116)
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:786)
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:758)
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:808)
at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1025)
at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:294)
at com.datastax.oss.driver.internal.core.channel.ChannelHandlerRequest.send(ChannelHandlerRequest.java:75)
at com.datastax.oss.driver.internal.core.channel.ProtocolInitHandler$InitRequest.send(ProtocolInitHandler.java:193)
at com.datastax.oss.driver.internal.core.channel.ProtocolInitHandler.onRealConnect(ProtocolInitHandler.java:124)
at com.datastax.oss.driver.internal.core.channel.ConnectInitHandler.lambda$connect$0(ConnectInitHandler.java:57)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491)
at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616)
at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:605)
at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104)
at io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:84)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:300)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:335)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:707)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.IllegalArgumentException: Can't find '[touch]' in io.netty.util.ReferenceCountUtil
at io.netty.util.ResourceLeakDetector.addExclusions(ResourceLeakDetector.java:576)
at io.netty.util.ReferenceCountUtil.<clinit>(ReferenceCountUtil.java:30)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
Also haven't dug into the underlying causes for this one yet.
I've been playing with this today and I have a few additional remarks: LZ4 CompressionI am trying to validate compression with lz4. It seems that it is not working:
Indeed, even if
We need all of the above unfortunately, including the abstract superclass TypeVariableThere is something fishy with
I still need to investigate. ServiceLoaderI manually validated that this is working by running the following code:
|
Also @absurdfarce would you mind rebasing this PR on top of 4.11.x? Otherwise we are going to hit JAVA-2950 during tests. |
Regarding lz4, what's even worse is that we cannot unconditionally add those LZ4 classes to reflection.json. If LZ4 is not present during image build, the build will fail. I think we need something like an |
Update: in fact the build succeeds, but generates warnings:
|
More on the
I guess we can consider that a bug in that GraalVM version and shovel it under the rug. |
ae92a06
to
93a394f
Compare
0566186
to
3ed3f4d
Compare
3dfe5c3
to
76c9ca6
Compare
Spun off of work done on JAVA-2940
Developed and tested as a feature branch off of #1559. Moved over to 4.11.x under the assumption we might want to fix this with a 4.11 release as well. Can always move it back if we decide not to do so.