Open marcinzh opened 2 months ago
Seems like we'd go with this syntax:
//> using jvm 11+
Note that we would not support this when a particular JVM distro is chosen, so:
//> using temurin:11+
// this is invalid
We'd support this via the CLI option --jvm
as well.
Is your feature request related to a problem? Please describe. I have a library that is compiled for Java 11. When running Scala-cli scripts, I need the JVM version to be at least 11, but the current directive
//> using jvm 11
causes Java 11 to be downloaded and used, even if the system already has a newer JVM version (e.g., Java 21) installed. This is undesirable, as I would prefer to use the newer JVM when available.Describe the solution you'd like I would like to be able to specify a minimum JVM version for my script. This would allow the script to run on any JVM that meets or exceeds the required version without forcing the download of an older JVM.
Proposed syntax:
Or:
Describe alternatives you've considered
Using the existing directive
//> using jvm 11
. However, this causes Java 11 to be downloaded, even when a newer version is already installed.Not using any directive at all. This approach results in an error when the script is executed, as the JVM may not meet the minimum version requirements and produces cryptic errors about class file versions. To diagnose the error, the user is forced to make a research about which JVM version corresponds to which class file version (e.g. Java 11 <-> class file format v55).
Additional context This feature would make it easier to work with projects requiring specific Java versions, without unnecessary downloads of older JVM versions when a suitable newer version is already installed.