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

scala.tools.nsc.javac.JavaParsers can't parse JDK15 Text Blocks (JEP 378) #12290

Closed
eed3si9n opened this issue Dec 19, 2020 · 3 comments · Fixed by scala/scala#9548
Closed

scala.tools.nsc.javac.JavaParsers can't parse JDK15 Text Blocks (JEP 378) #12290

eed3si9n opened this issue Dec 19, 2020 · 3 comments · Fixed by scala/scala#9548

Comments

@eed3si9n
Copy link
Member

This was originally reported as sbt/sbt#6208 by @larousso

reproduction steps

$ java -version
openjdk version "15.0.1" 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.1+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15.0.1+9, mixed mode, sharing)

build.sbt

ThisBuild / scalaVersion     := "2.13.4"
ThisBuild / version          := "0.1.0-SNAPSHOT"

lazy val root = (project in file("."))
  .settings(
    name := "hello",
    // Compile / compileOrder := CompileOrder.JavaThenScala,
  )

src/main/java/example/A.java

package example;

class A {
  private String aText = """
    A text
    """;
}

problem

sbt:hello> compile
[info] compiling 1 Scala source and 1 Java source to /private/tmp/hello/target/scala-2.13/classes ...
[error] /private/tmp/hello/src/main/java/example/A.java:4:29: unclosed string literal
[error]   private String aText = """
[error]                             ^
[error] /private/tmp/hello/src/main/java/example/A.java:6:8: unclosed string literal
[error]     """;
[error]        ^
[error] /private/tmp/hello/src/main/java/example/A.java:7:2: `;` expected but eof found.
[error] }
[error]  ^
[error] three errors found
[error] (Compile / compileIncremental) Compilation failed

expectation

No errors.

notes

https://openjdk.java.net/jeps/378

The workaround is to use Compile / compileOrder := CompileOrder.JavaThenScala.

See also:

@SethTisue SethTisue added this to the Backlog milestone Dec 19, 2020
harpocrates added a commit to harpocrates/scala that referenced this issue Mar 23, 2021
JDK15 introduced text blocks (JEP 378) for writing multiline strings.
This adds support for parsing these strings in the Java parser.

The logic for interpretting the literals is a little complicated, but
follows from the "3.10.6. Text Blocks" of the Java language specification.
The test cases include examples from there and from the JEP.

Fixes scala/bug#12290
harpocrates added a commit to harpocrates/scala that referenced this issue Mar 24, 2021
JDK15 introduced text blocks (JEP 378) for writing multiline strings.
This adds support for parsing these strings in the Java parser.

The logic for interpretting the literals is a little complicated, but
follows from the "3.10.6. Text Blocks" of the Java language specification.
The test cases include examples from there and from the JEP.

Fixes scala/bug#12290
harpocrates added a commit to harpocrates/scala that referenced this issue Mar 24, 2021
JDK15 introduced text blocks (JEP 378) for writing multiline strings.
This adds support for parsing these strings in the Java parser.

The logic for interpretting the literals is a little complicated, but
follows from the "3.10.6. Text Blocks" of the Java language specification.
The test cases include examples from there and from the JEP.

Fixes scala/bug#12290
harpocrates added a commit to harpocrates/scala that referenced this issue Mar 26, 2021
JDK15 introduced text blocks (JEP 378) for writing multiline strings.
This adds support for parsing these strings in the Java parser.

The logic for interpretting the literals is a little complicated, but
follows from the "3.10.6. Text Blocks" of the Java language specification.
The test cases include examples from there and from the JEP.

Fixes scala/bug#12290
@SethTisue
Copy link
Member

@harpocrates if you comment on this ticket, I can assign it to you (merely for credit/glory)

@SethTisue SethTisue modified the milestones: Backlog, 2.13.6 Apr 23, 2021
@harpocrates
Copy link

Imaginary internet credit and glory points? Sign me up! 😆

@SethTisue
Copy link
Member

cha-ching!

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

Successfully merging a pull request may close this issue.

3 participants