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

java12 flag --enable-preview has no effect #5021

apflieger opened this issue Sep 2, 2019 · 3 comments


Copy link

commented Sep 2, 2019


sbt version: 1.3.0-RC5

java -version
openjdk 12.0.2 2019-07-16
OpenJDK Runtime Environment (build 12.0.2+10)
OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)

macOS Mojave 10.14.6


I'm trying to use preview features of java12, so I need to pass these options:

javacOptions ++= Seq("--release", "12", "--enable-preview")
javaOptions += "--enable-preview"

javac options works. My classes are compiled using --enable-preview
But the runtime refuses to run. I get there errors :

Error reading API from class file: com.mycompany.SomeClass : java.lang.UnsupportedClassVersionError: Preview features are not enabled for com/mycompany/SomeClass (class file version 56.65535). Try running with '--enable-preview'


  • It works if I set JAVA_OPTS='--enable-preview'.
  • IntelliJ doesn't recognize the flag either (the project structure is taken from build.sbt).

@apflieger apflieger added the Bug label Sep 2, 2019


This comment has been minimized.

Copy link

commented Sep 2, 2019

Thanks for the report, but javaOptions only take effect under forking -, so I think it's working as expected.
I guess it would be useful to have forked compilation in this kind of situation, but sbt doesn't directly support (it might indirectly via javaHome).

@eed3si9n eed3si9n added not-a-🐛 and removed Bug labels Sep 2, 2019


This comment has been minimized.

Copy link

commented Sep 2, 2019

The behavior is quite weird : the errors happen during the compile task but the classes are correclty compiled. Then I run test and nothing happen. 0 tests are executed and the build succeed.
Adding fork := true doesn't solve it

Do I have a choice but to set it on sbt's runtime?


This comment has been minimized.

Copy link

commented Sep 2, 2019

Currently the compilation happens mostly within the same JVM, so you'd have to specify the flag when you start sbt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.