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

support JEP 476: Module Import Declarations in JavaParsers #13005

Open
xuwei-k opened this issue Jun 7, 2024 · 2 comments
Open

support JEP 476: Module Import Declarations in JavaParsers #13005

xuwei-k opened this issue Jun 7, 2024 · 2 comments

Comments

@xuwei-k
Copy link

xuwei-k commented Jun 7, 2024

Reproduction steps

https://openjdk.org/jeps/476

Scala version: 2.13.14

$ java --version
openjdk 23-ea 2024-09-17
OpenJDK Runtime Environment (build 23-ea+25-2094)
OpenJDK 64-Bit Server VM (build 23-ea+25-2094, mixed mode, sharing)

B.scala

class B

A.java

import module java.base;

public class A {
}

build.sbt

javacOptions ++= Seq("--enable-preview", "--release", scala.util.Properties.javaSpecVersion)

scalaVersion := "2.13.14"

project/build.properties

sbt.version=1.10.0

Problem

run sbt compile

[error] my-example-project-path/A.java:1:15: `;` expected but identifier found.
[error] import module java.base;
[error]               ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

workaround

set compileOrder := CompileOrder.JavaThenScala or compileOrder := CompileOrder.ScalaThenJava in sbt

@som-snytt
Copy link

The Java feature is mostly about prototyping and JShell. It would be nice if -Yimports handled modules.

scala -Yimports:java.lang,scala,scala.Predef,scala.annotation,scala.util.chaining
becomes
scala -Yimports:java.base,scala,scala.Predef,scala.annotation,scala.util.chaining
where for conflicts between module and package names it could support
scala -Yimports:module java.base,etc
or someday just
scala -Yimports:java.base,scala.base

@SethTisue
Copy link
Member

would it be useful for our parser to accept but ignore such imports? or does it need to actually take action in order for the change to be useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants