Open taig opened 3 years ago
Thank you for reporting! Can you confirm that --initialize-at-run-time=scala.util.Random$
fixes the problem? We can certainly enable something like that by default in this plugin.
After adding the option to my build, the native-image generation passed without issues again and the executables are doing fine in production. As this is a Scala-related issue, this project seems to be the best place to handle it. However, I have poor understanding of the native-image mechanics and don't fully get why this change became necessary, so I figured I'll contribute this as a suggestion and get some more eyes on it.
The issue did of course also pop up in numerous Java libraries which also appear to be resolved via runtime init https://github.com/quarkusio/quarkus/issues/14904.
If you agree with the approach, I would be happy to submit a PR.
GraalVM 21.1.0 has just been released, but my builds are failing unfortunately.
Steps to reproduce the behavior
sbt/nativeImage
on code that referencesscala.util.Random$
Solution
scala.util.Random$
extendsscala.util.Random
and thereby causes a static initialization ofjava.util.Random
which is not allowed, as the error message above suggests. I believe we should therefore add--initialize-at-run-time=scala.util.Random$
to the default options of this plugin.