-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Preview compiler features in a mixed Java/Scala Project #727
Comments
Many many thanks. That solved the issue I mentioned, but there is still one issue: When I actually use Java 21's String templates, e.g. by running
, which makes sense from the point of view of previous Java versions, but not Java 21. Moreover, |
Please provide a reproducer as described here: https://stackoverflow.com/help/minimal-reproducible-example. |
and then io.aghasmi.Tests.java: package io.aghasemi;
import static java.lang.StringTemplate.STR;
public class Tests {
public static void main(String[] args) {
System.out.println(STR."=\{2+2}");
return;
}
} Temurin JDk 21 and Maven 3.9.4. |
Could you please:
|
Here it is: https://github.com/aghasemi/mavan-scala-java21-test Thanks |
I have the exact same error with sbt. Nothing we can do on our side. scala-maven-plugin will support automatically it once scalac supports it. |
I see. Thanks. Quite a bit of a shame since the Scala compiler is actually OK with the preview features, except for this extension to escape characters it seems. Would not happen if |
2 different things: being able to pass the javac option to enable features in preview and specifically being able to parse this new Java code. Might be related to the version of asm currently shipped. Anyway, nothing we can do here. I recommend that you open an issue directly against Scala. |
Thanks. I will. Just out of curiosity, why should the Scala compiler parse a Java source file? |
So it can figure out the types and methods in Java code and compile the Scala code that might import them. But it just parses Java sources, it doesn't compile them in bytecode, javac is used for that. |
Of course! Many thanks. |
Hi,
I have a project with both Java and Scala sources, and I want to use a preview feature of Java 21 (String templates) in the Java code. However, building the project with
mvn compile
results in:I have set
--enable-preview
in the maven compiler plugin, but the maven scala compiler does not have such a feature, does it? Is there anything I can do to have my Java code compiled, or preview features are unusable intentionally? By the way, Java 21 works fine with the plugin otherwise, and other new features of Java 21 such as pattern matching and virtual threads work as intended.Many thanks
The text was updated successfully, but these errors were encountered: