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

Text Block syntax unsupported by turbine, making valid java 15 syntax fail bazel build #15083

Closed
nresare opened this issue Mar 21, 2022 · 3 comments
Assignees
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Java Issues for Java rules

Comments

@nresare
Copy link
Contributor

nresare commented Mar 21, 2022

Description of the problem / feature

The java Text Block was landed as JEP 378 in Java 15. Unfortunately, it seems all recent versions of bazel fails to accept the text block syntax when the turbine header compiler is used.

Looking at the main branch of the turbine lexer, it is clear that it does not have support for Text Blocks and will fail parsing any input java file containing the new syntax.

A workaround for now is to add the --nojava_header_compilation command line option.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Any bazel build invocation which invokes the turbine header compiler on a file that contains a JEP 378 style text block will illustrate the problem. For example if a java_binary target depends on a java_library target which has a text block in one of it's source files. I created https://github.com/nresare/bazel-multiline-problem as a minimal test project.

$ git clone https://github.com/nresare/bazel-multiline-problem
$ bazelisk build //:test

Expected outcome: successful build
Actual outcome:

error executing command external/remotejdk17_macos_aarch64/bin/java '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' ... (remaining 36 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Multiline.java:2: error: unterminated string literal
    String s = """
                  ^
<snip>

What operating system are you running Bazel on?

MacOS 12.3, MacBook Air M1

What's the output of bazel info release?

release 5.0.0

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

This problem is also visible when building from lastest master, I tried just now with 00d74ff

What's the output of git remote get-url origin ; git rev-parse main ; git rev-parse HEAD ?

$ git remote get-url origin ; git rev-parse main ; git rev-parse HEAD
[email protected]:nresare/bazel-multiline-problem.git
e9b12dbf08c12974c0f76fcd2dd40d6c40bc15f3
e9b12dbf08c12974c0f76fcd2dd40d6c40bc15f3

Have you found anything relevant by searching the web?

I did a casual search among the issues, but failed to find this reported previously.

@nresare nresare changed the title Text Blocks Text Block syntax unsupported by turbine Mar 21, 2022
@nresare nresare changed the title Text Block syntax unsupported by turbine Text Block syntax unsupported by turbine, making valid java 15 syntax fail bazel build Mar 21, 2022
@sgowroji sgowroji added team-Configurability platforms, toolchains, cquery, select(), config transitions team-Rules-Java Issues for Java rules untriaged and removed team-Configurability platforms, toolchains, cquery, select(), config transitions labels Mar 21, 2022
@comius
Copy link
Contributor

comius commented Mar 21, 2022

Our current tests are only covering java_binary, which doesn't cover turbine.

As soon as text block is in a library, turbine breaks.

cc @cushon

@comius comius added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Mar 21, 2022
@comius comius removed their assignment Mar 21, 2022
@cushon cushon self-assigned this Mar 23, 2022
cushon added a commit to cushon/bazel that referenced this issue Mar 23, 2022
@vorburger
Copy link
Contributor

FTR: It looks like this regressed; it appears to be broken (still or again; haven't tested) at least in Bazel 7.0.0 & 7.0.2.

@cushon
Copy link
Contributor

cushon commented Jan 28, 2024

FTR: It looks like this regressed; it appears to be broken (still or again; haven't tested) at least in Bazel 7.0.0 & 7.0.2.

This bug is about text blocks, which is a different language feature from string templates. I responded in #21119

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Java Issues for Java rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants