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

Print out the full Java version #2975

Open
naferx opened this issue Jun 22, 2024 · 0 comments · May be fixed by #2994
Open

Print out the full Java version #2975

naferx opened this issue Jun 22, 2024 · 0 comments · May be fixed by #2994
Labels
enhancement New feature or request jvm Issues tied to the JVM platform UX

Comments

@naferx
Copy link
Contributor

naferx commented Jun 22, 2024

Is your feature request related to a problem? Please describe.

When executing a Scala script, scala-cli reports the Scala and Java version used.

$ echo 'println("hello world")' | scala-cli -
Compiling project (Scala 3.4.2, JVM (17))
Compiled project (Scala 3.4.2, JVM (17))
hello world

As noted, for Scala it shows the $MAJOR.$MINOR.$SECURITY version scheme but for Java it only prints out the $MAJOR part.

I'd like to know the full Java version used by scala-cli when not providing it via directives like //> using jvm 21.0.2 or command option --jvm 21.0.2. i.e

$ echo 'println("hello world")' | scala-cli --jvm 21.0.2 -
Compiling project (Scala 3.4.2, JVM (21.0.2))
Compiled project (Scala 3.4.2, JVM (21.0.2))
hello world

I have two reasons for this feature request:

  1. Debugging purposes, in case that by manual installation or using tools such as sdkman a machine has two similar Java versions
    x.y1.z1 and x.y2.z2 where x is the same in both installations.

  2. For consistency because the other platforms; Scala, Javascript and Scala-Native do report the full version since
    9d47089 (Merge pull request Bump Scala Native to 0.4.16 & log platform version #2465 from Gedochao/maintenance/scala-native-improvements, 2023-10-17)

Describe the solution you'd like
When running a script, it reports the full Java version being used

i.e

$ echo 'println("hello world")' | scala-cli -
Compiling project (Scala 3.4.2, JVM (17.0.11))
Compiled project (Scala 3.4.2, JVM (17.0.11))
hello world

Describe alternatives you've considered
If this feature request is not incorporated, and one would like to know the Java version, it would be necessary to inspect the Java version before hand via typing java --version

$ java --version 
openjdk 17.0.11 2024-04-16
OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9)
OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode, sharing)

Additional context

After having a preliminary code revision, it seems like the change can be introduced in scala.build.options.BuildOptions#projectParams

Additionally, as stated in https://openjdk.org/jeps/223. There is a set of system properties that can be used to extract the version.

@naferx naferx added the enhancement New feature or request label Jun 22, 2024
@Gedochao Gedochao added UX java Issues tied to compiling & running of Java code jvm Issues tied to the JVM platform and removed java Issues tied to compiling & running of Java code labels Jun 24, 2024
@naferx naferx linked a pull request Jun 28, 2024 that will close this issue
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 UX
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants