From 540798b970f34e9c32e18eddee6af1cf29aa4013 Mon Sep 17 00:00:00 2001 From: Pete Woods Date: Mon, 7 Oct 2019 08:02:13 +0100 Subject: [PATCH] Add `io.netty.handler.codec.http2.Http2ConnectionHandler` for runtime GraalVM compilation (#9621) Motivation: Native image compilation is failing without extra flags: ``` Warning: Aborting stand-alone image build. No instances of io.netty.buffer.UnpooledHeapByteBuf are allowed in the image heap as this class should be initialized at image runtime. Object has been initialized by the io.netty.handler.codec.http2.Http2ConnectionHandler class initializer with a trace: at io.netty.buffer.Unpooled.wrappedBuffer(Unpooled.java:157) at io.netty.handler.codec.http2.Http2ConnectionHandler.(Http2ConnectionHandler.java:74) . To fix the issue mark io.netty.buffer.UnpooledHeapByteBuf for build-time initialization with --initialize-at-build-time=io.netty.buffer.UnpooledHeapByteBuf or use the the information from the trace to find the culprit and --initialize-at-run-time= to prevent its instantiation. Detailed message: Trace: object io.netty.buffer.ReadOnlyByteBuf object io.netty.buffer.UnreleasableByteBuf method io.netty.handler.codec.http2.Http2ConnectionHandler.access$500() Call path from entry point to io.netty.handler.codec.http2.Http2ConnectionHandler.access$500(): at io.netty.handler.codec.http2.Http2ConnectionHandler.access$500(Http2ConnectionHandler.java:66) at io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.readClientPrefaceString(Http2ConnectionHandler.java:299) at io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.decode(Http2ConnectionHandler.java:239) at io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:438) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:505) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:444) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:283) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:56) at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:365) at com.oracle.svm.core.jdk.RuntimeSupport.executeHooks(RuntimeSupport.java:144) at com.oracle.svm.core.jdk.RuntimeSupport.executeStartupHooks(RuntimeSupport.java:89) at com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:143) at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186) at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0) ``` Modification: Add `io.netty.handler.codec.http2.Http2ConnectionHandler` for runtime compilation, as the buffer library's `io.netty.buffer.UnpooledHeapByteBuf` is also marked for runtime. Result: Native image compilation works again. --- .../native-image/io.netty/codec-http2/native-image.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec-http2/src/main/resources/META-INF/native-image/io.netty/codec-http2/native-image.properties b/codec-http2/src/main/resources/META-INF/native-image/io.netty/codec-http2/native-image.properties index 0124328b8a..ed5e345dd0 100644 --- a/codec-http2/src/main/resources/META-INF/native-image/io.netty/codec-http2/native-image.properties +++ b/codec-http2/src/main/resources/META-INF/native-image/io.netty/codec-http2/native-image.properties @@ -13,4 +13,4 @@ # under the License. Args = --initialize-at-build-time=io.netty \ - --initialize-at-run-time=io.netty.handler.codec.http2.Http2CodecUtil,io.netty.handler.codec.http2.Http2ClientUpgradeCodec,io.netty.handler.codec.http2.DefaultHttp2FrameWriter + --initialize-at-run-time=io.netty.handler.codec.http2.Http2CodecUtil,io.netty.handler.codec.http2.Http2ClientUpgradeCodec,io.netty.handler.codec.http2.Http2ConnectionHandler,io.netty.handler.codec.http2.DefaultHttp2FrameWriter