Skip to content

Directive for specifying minimum JVM version #3205

Open
@marcinzh

Description

@marcinzh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestjvmIssues tied to the JVM platform

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions