Issue
I am trying to compile this project with GraalVM native-image on macOS and it fails with a link issue.
Steps to reproduce the issue
Please include both build steps as well as run steps
Describe GraalVM and your environment:
More details
See repo README.
This looks like a duplicate of #2063.
Thanks. I'll try with GraalVM dev 20.3.0.
@fniephaus I'm getting a different error with 20.3.0 (java 11):
Error: Incompatible change of initialization policy for java.lang.Math$RandomNumberGeneratorHolder: trying to change RUN_TIME from the command line to RERUN for random number generator
com.oracle.svm.core.util.UserError$UserException: Incompatible change of initialization policy for java.lang.Math$RandomNumberGeneratorHolder: trying to change RUN_TIME from the command line to RERUN for random number generator
What happens if you remove RandomNumberGeneratorHolder from
https://github.com/borkdude/console-tetris/blob/20d0d3bd4e764cd67ff676c751be9b0e7e6acc1c/script/compile#L15
?
@fniephaus Then I get a new error:
Error: No instances of java.awt.color.ICC_ColorSpace are allowed in the image heap as this class should be initialized at image runtime. To see how this object got instantiated use --trace-object-instantiation=java.awt.color.ICC_ColorSpace.
Detailed message:
Trace: Object was reached by
reading field java.awt.image.ColorModel.colorSpace of
constant java.awt.image.DirectColorModel@2ee448f5 reached by
reading field sun.java2d.SurfaceData.colorModel of
constant sun.java2d.NullSurfaceData@54443846 reached by
scanning method sun.java2d.SunGraphics2D.revalidateAll(SunGraphics2D.java:2448)
Call path from entry point to sun.java2d.SunGraphics2D.revalidateAll():
at sun.java2d.SunGraphics2D.revalidateAll(SunGraphics2D.java:2446)
at sun.java2d.SunGraphics2D.fillRect(SunGraphics2D.java:2427)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:584)
at javax.swing.RepaintManager$4.run(RepaintManager.java:876)
at javax.swing.RepaintManager$4.run(RepaintManager.java:848)
at com.oracle.svm.core.jdk.Target_java_security_AccessController.doPrivileged(SecuritySubstitutions.java:102)
at sun.security.ssl.TransportContext$NotifyHandshake.run(TransportContext.java:657)
at java.lang.Thread.run(Thread.java:834)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
When adding "--initialize-at-run-time=java.awt.color.ICC_ColorSpace" I get:
Error: Classes that should be initialized at run time got initialized during image building:
java.awt.color.ICC_ColorSpace the class was requested to be initialized at run time (from the command line). To see why java.awt.color.ICC_ColorSpace got initialized use --trace-class-initialization=java.awt.color.ICC_ColorSpace
I'm afraid you are out of luck: the project you are compiling depends on AWT/Swing which is not yet supported by native image (see #2644 for example).
@fniephaus No problem. I switched over the terminal to text instead of Swing and now it works with 20.2.0 :)