rules_scala
rules_scala copied to clipboard
Java 18 and 19 SecurityManager handling
rules_scala doesn't work out of the box with Java 18 or 19, since Worker.java makes use of a SecurityManager, which is not allowed by default as of Java 18. See https://openjdk.org/jeps/411.
Since there is no replacement API to trap System.exit yet, the solution is to pass -Djava.security.manager=allow to the JVM running the worker.
It is possible to do this explicitly in my own project by passing the flag via scalac_jvm_flags in my Scala toolchain, but I was wondering if we should do something in rules_scala to make this more obvious to new users?
Sadly I don't think it will work to pass the flag always, since older JDKs don't understand the flag.
Adding a bit to the README about this might be good enough. Alternatively rules_scala could pass that flag to the worker automatically if the JVM it will use is 18+ (I'm not sure how best to detect this in Starlark, parsing java --version maybe?).