Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directive for specifying minimum JVM version #3205

Open
marcinzh opened this issue Sep 25, 2024 · 1 comment
Open

Directive for specifying minimum JVM version #3205

marcinzh opened this issue Sep 25, 2024 · 1 comment
Labels
enhancement New feature or request jvm Issues tied to the JVM platform

Comments

@marcinzh
Copy link

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:

//> using jvm 11+

Or:

//> using jvm >= 11

Describe alternatives you've considered

  1. Using the existing directive //> using jvm 11 . However, this causes Java 11 to be downloaded, even when a newer version is already installed.

  2. 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.

@marcinzh marcinzh added the enhancement New feature or request label Sep 25, 2024
@Gedochao Gedochao added the jvm Issues tied to the JVM platform label Sep 25, 2024
@Gedochao
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jvm Issues tied to the JVM platform
Projects
None yet
Development

No branches or pull requests

2 participants