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

[java] Broken TextBlock parser #4947

Closed
rs23 opened this issue Apr 10, 2024 · 0 comments · Fixed by #4958
Closed

[java] Broken TextBlock parser #4947

rs23 opened this issue Apr 10, 2024 · 0 comments · Fixed by #4958
Labels
a:bug PMD crashes or fails to analyse a file. has:pr The issue is already tackled in a PR in:grammar About the grammar of a lexer or parser, eg, a parse/lex exception
Milestone

Comments

@rs23
Copy link

rs23 commented Apr 10, 2024

Affects PMD Version:

7.0.0

Description:

Parse exception in text block, if followed by a String template.

Exception Stacktrace:

ImageRecorder.java      -       ParseException: Parse exception in file 
'ImageRecorder.java' at line 2, column 21: Encountered 
<TEXT_BLOCK_TEMPLATE_BEGIN: "\"\"\"\n                    x\"\"\";\n\n//     STR.\"\\{">.
Was expecting:
    "{" ...
[main] INFO net.sourceforge.pmd.cli - An error occurred while executing PMD.

Code Sample demonstrating the issue:

public class ImageRecorder {
  String digits = """
                  x""";
  //     STR."\{1}");
}

Steps to reproduce:

java -cp "lib/*" net.sourceforge.pmd.cli.PmdCli check --verbose  --no-progress --no-cache --use-version java-22-preview -R ruleset.xml -d ImageRecorder.java

Running PMD through: CLI

ruleset.xml:

<?xml version="1.0"?>
<ruleset name="sample">
<description/>
<rule ref="category/java/errorprone.xml"/>
</ruleset>
@rs23 rs23 added the a:bug PMD crashes or fails to analyse a file. label Apr 10, 2024
@jsotuyod jsotuyod added the in:grammar About the grammar of a lexer or parser, eg, a parse/lex exception label Apr 10, 2024
oowekyala added a commit to oowekyala/pmd that referenced this issue Apr 12, 2024
@jsotuyod jsotuyod added the has:pr The issue is already tackled in a PR label Apr 12, 2024
@oowekyala oowekyala added this to the 7.1.0 milestone Apr 15, 2024
jsotuyod added a commit that referenced this issue Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file. has:pr The issue is already tackled in a PR in:grammar About the grammar of a lexer or parser, eg, a parse/lex exception
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants