oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.36k stars 1.63k forks source link

[native-image] Detected a started Thread in the image heap when including java.awt.Toolkit in reflection list #2123

Closed maxum2610 closed 9 months ago

maxum2610 commented 4 years ago

When I include java.awt.Toolkit in the reflection list like so: { "name" : "java.awt.Toolkit", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredFields" : true, "allPublicFields" : true, "allDeclaredMethods" : true, "allPublicMethods" : true }

I get and error on class sun.awt.AWTAutoShutdown which does start a thread .

openjdk version "11.0.6" 2020-01-14 OpenJDK Runtime Environment GraalVM CE 19.3.1 (build 11.0.6+9-jvmci-19.3-b07) OpenJDK 64-Bit Server VM GraalVM CE 19.3.1 (build 11.0.6+9-jvmci-19.3-b07, mixed mode, sharing) OS is MacOS 10.14.5

Error: Unsupported features in 2 methods Detailed message: Error: Detected a started Thread in the image heap. Threads running in the image generator are no longer running at image run time. Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-build-time=. Or you can write your own initialization methods and call them explicitly from your main entry point. Trace: object sun.awt.AWTAutoShutdown method sun.awt.AWTAutoShutdown.getInstance() Call path from entry point to sun.awt.AWTAutoShutdown.getInstance(): at sun.awt.AWTAutoShutdown.getInstance(AWTAutoShutdown.java:132) at java.awt.EventQueue.detachDispatchThread(EventQueue.java:1152) at java.awt.EventDispatchThread.run(EventDispatchThread.java:96) at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:497) at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193) at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0) Error: Detected a started Thread in the image heap. Threads running in the image generator are no longer running at image run time. Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-build-time=. Or you can write your own initialization methods and call them explicitly from your main entry point. Trace: object sun.java2d.opengl.OGLRenderQueue$QueueFlusher object sun.java2d.opengl.OGLRenderQueue field sun.java2d.opengl.OGLRenderQueue.theInstance

com.oracle.svm.core.util.UserError$UserException: Unsupported features in 2 methods Detailed message: Error: Detected a started Thread in the image heap. Threads running in the image generator are no longer running at image run time. Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-build-time=. Or you can write your own initialization methods and call them explicitly from your main entry point. Trace: object sun.awt.AWTAutoShutdown method sun.awt.AWTAutoShutdown.getInstance() Call path from entry point to sun.awt.AWTAutoShutdown.getInstance(): at sun.awt.AWTAutoShutdown.getInstance(AWTAutoShutdown.java:132) at java.awt.EventQueue.detachDispatchThread(EventQueue.java:1152) at java.awt.EventDispatchThread.run(EventDispatchThread.java:96) at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:497) at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193) at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0) Error: Detected a started Thread in the image heap. Threads running in the image generator are no longer running at image run time. Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-build-time=. Or you can write your own initialization methods and call them explicitly from your main entry point. Trace: object sun.java2d.opengl.OGLRenderQueue$QueueFlusher object sun.java2d.opengl.OGLRenderQueue field sun.java2d.opengl.OGLRenderQueue.theInstance

at com.oracle.svm.core.util.UserError.abort(UserError.java:75)
at com.oracle.svm.hosted.FallbackFeature.reportAsFallback(FallbackFeature.java:221)
at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:736)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:530)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
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:177)

Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported features in 2 methods Detailed message: Error: Detected a started Thread in the image heap. Threads running in the image generator are no longer running at image run time. Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-build-time=. Or you can write your own initialization methods and call them explicitly from your main entry point. Trace: object sun.awt.AWTAutoShutdown method sun.awt.AWTAutoShutdown.getInstance() Call path from entry point to sun.awt.AWTAutoShutdown.getInstance(): at sun.awt.AWTAutoShutdown.getInstance(AWTAutoShutdown.java:132) at java.awt.EventQueue.detachDispatchThread(EventQueue.java:1152) at java.awt.EventDispatchThread.run(EventDispatchThread.java:96) at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:497) at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193) at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0) Error: Detected a started Thread in the image heap. Threads running in the image generator are no longer running at image run time. Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-build-time=. Or you can write your own initialization methods and call them explicitly from your main entry point. Trace: object sun.java2d.opengl.OGLRenderQueue$QueueFlusher object sun.java2d.opengl.OGLRenderQueue field sun.java2d.opengl.OGLRenderQueue.theInstance

at com.oracle.graal.pointsto.constraints.UnsupportedFeatures.report(UnsupportedFeatures.java:129)
at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:733)
... 8 more

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) at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1665)

fernando-valdez commented 9 months ago

Thanks for reporting this issue. As the native image and the agent have been heavily improved since 2020, I am closing this ticket assuming it has been fixed. If that is not the case, please test the latest release and share the new error log.