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

//> using jvm isn't respected for JVMs >17 #2969

Closed
Gedochao opened this issue Jun 17, 2024 · 0 comments · Fixed by #2972
Closed

//> using jvm isn't respected for JVMs >17 #2969

Gedochao opened this issue Jun 17, 2024 · 0 comments · Fixed by #2972
Assignees
Labels
Bloop Issues tied with Bloop integration. bug Something isn't working java Issues tied to compiling & running of Java code

Comments

@Gedochao
Copy link
Contributor

Gedochao commented Jun 17, 2024

Version(s)
v1.3.2

Describe the bug
Bloop JVM seems to only respect the --jvm command line flag, while completely ignoring the //> using jvm directive.

To Reproduce
Stop Bloop if it's running

scala-cli bloop exit --power
# Stopped Bloop server.

Try running the following code as Simple.java:

// Simple.java
//> using jvm 22
//> using javacOpt --enable-preview -Xlint:preview
//> using javaOpt --enable-preview
//> using mainClass Simple

void main() {
    System.out.println("Hello from Java 22");
}
scala-cli Simple.java
# Starting compilation server
# [warn]  JVM that is hosting bloop is older than the requested runtime. Please restart the Build Server from your IDE.
# [warn] Or run the command `bloop exit`, and then use `--jvm` flag to request a sufficient JVM version.
# [warn] COMMAND_LINE
# [warn] [current bloop jvm] /Users/pchabelski/Library/Caches/Coursier/arc/https/github.com/adoptium/temurin17-binaries/releases/download/jdk-17%252B35/OpenJDK17-jdk_aarch64_mac_hotspot_17_35.tar.gz/jdk-17+35/Contents/Home

Despite bloop being killed and //> using jvm 22 in the code, Scala CLI still asks for the --jvm flag to be passed to run this code.

Running with --jvm 22 works fine:

# scala-cli Simple.java --jvm 22
# Starting compilation server
# Compiling project (Java)
# Annotation processing is enabled because one or more processors were found
#   on the class path. A future release of javac may disable annotation processing
#   unless at least one processor is specified by name (-processor), or a search
#   path is specified (--processor-path, --processor-module-path), or annotation
#   processing is enabled explicitly (-proc:only, -proc:full).
#   Use -Xlint:-options to suppress this message.
#   Use -proc:none to disable annotation processing.
# [warn] ./Simple.java:7:1
# [warn] implicitly declared classes are a preview feature and may be removed in a future release.
# [warn] void main() {
# [warn] ^
# Warning: Error reading API from class file: Simple : java.lang.UnsupportedClassVersionError: Preview features are not # enabled for Simple (class file version 66.65535). Try running with '--enable-preview'
# Compiled project (Java)
# Hello from Java 22

Expected behaviour
I'd expect the --jvm command line option and //> using jvm directive to be interchangeable here.

@Gedochao Gedochao added bug Something isn't working java Issues tied to compiling & running of Java code Bloop Issues tied with Bloop integration. labels Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bloop Issues tied with Bloop integration. bug Something isn't working java Issues tied to compiling & running of Java code
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants