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

Native image generation fails with Netty 4.1.44.Final #9918

Open
tovbinm opened this issue Jan 3, 2020 · 3 comments
Open

Native image generation fails with Netty 4.1.44.Final #9918

tovbinm opened this issue Jan 3, 2020 · 3 comments

Comments

@tovbinm
Copy link

tovbinm commented Jan 3, 2020

Expected behavior

A working native image

Actual behavior

When I am trying to generate a native image on a project with Netty dependency I get the following error:

Error: Classes that should be initialized at run time got initialized during image building:
 io.netty.channel.DefaultFileRegion the class was requested to be initialized at build time (subtype of io.netty.util.AbstractReferenceCounted and from the command line). io.netty.channel.DefaultFileRegion has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of io.netty.channel.DefaultFileRegion
io.netty.util.AbstractReferenceCounted the class was requested to be initialized at build time (from the command line). io.netty.util.AbstractReferenceCounted has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of 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.channel.DefaultFileRegion the class was requested to be initialized at build time (subtype of io.netty.util.AbstractReferenceCounted and from the command line). io.netty.channel.DefaultFileRegion has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of io.netty.channel.DefaultFileRegion
io.netty.util.AbstractReferenceCounted the class was requested to be initialized at build time (from the command line). io.netty.util.AbstractReferenceCounted has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of io.netty.util.AbstractReferenceCounted
	at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
	at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:510)
	at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:187)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:710)
	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:710)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:530)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
	at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
	at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1482)
	at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1260)
	at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1222)
	at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1181)

Steps to reproduce

"Hello world" server with 4.1.44.Final dependency

Minimal yet complete reproducer code (or URL to code)

N/A

Netty version

4.1.44.Final

JVM version (e.g. java -version)

$ docker run oracle/graalvm-ce:19.3.0.2 sh -c "java -version"
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b07)
OpenJDK 64-Bit GraalVM CE 19.3.0.2 (build 25.232-b07-jvmci-19.3-b06, mixed mode)

OS version (e.g. uname -a)

$ docker run oracle/graalvm-ce:19.3.0.2 sh -c "uname -a"
Linux 161cd47fc3af 4.9.184-linuxkit #1 SMP Tue Jul 2 22:58:16 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

(I also opened a similar issue here - oracle/graal#2050)

@normanmaurer
Copy link
Member

@tovbinm we love contributions. If you have any idea how to fix this I am happy to review a pr.

@tovbinm
Copy link
Author

tovbinm commented Jan 9, 2020

I have been told here - oracle/graal#2050 that it should be possible, but I failed to confirm yet.

@keddie
Copy link

keddie commented Feb 5, 2020

I saw exactly this symptom in a different project. The cause was that my agent-generated reflect.config contained:

{
  "name":"io.netty.channel.epoll.Epoll"
},
{
  "name":"io.netty.channel.epoll.EpollSocketChannel",
  "methods":[{"name":"<init>","parameterTypes":[] }]
},

... which was causing AbstractReferenceCounted to initialize.

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
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

3 participants