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
Parse exception for RAW string template (Java 21+) #14793
Comments
…emplate and raw string template as reported in issue checkstyle#14793
Checkstyle is currently unable to parse this syntax. there is an open issue for this #14195 (comment) |
@nrmancuso , |
This example is not valid syntax. Text blocks must begin with three quotes and a newline character. I am removing the approved label since this is a duplicate of #14195 It is unlikely that we will ever support this syntax, since Java themselves have dropped it: #14805 I suggest that we close this issue and continue any discussion at #14195 |
In Java 21/22, when using a String template with a raw String, checkstyle fails with a parsing error:
Maven checkstyle output:
I have verified this issue by adding
to the Checkstyle's
com/puppycrawl/tools/checkstyle/grammar/java21/InputStringTemplateBasic.java
test case.See updated test case InputStringTemplateBasic.java
The test fails with
Java21AstRegressionTest.testBasicStringTemplate:42->AbstractTreeTestSupport.verifyAst:77->AbstractTreeTestSupport.verifyAst:57 » Checkstyle IllegalStateException occurred while parsing file /Users/dhl/Project/others/checkstyle/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/grammar/java21/InputStringTemplateBasic.java
Using a raw string with a String Template is valid syntax. See Java 21 String Templates: Multiline String Templates and Java 22 String Templates: Multiline String Template
Also using
StringTemplate.RAW
, which is an alternative notation ofSTR.""".."""
fails with a parse error.Java Api Docs StringTemplate
Tested with:
Java: 21 and 22
Checkstyle: 10.14 and 10.15
The text was updated successfully, but these errors were encountered: