Repository navigation
Description
Affects PMD Version: 7.25.0 (also reproduced on 7.23.0 and 7.6.0)
Description:
PMD fails to parse valid Apex code that uses Summer '26 multiline string literals ('''...''').
The Apex platform now accepts triple-single-quoted multiline strings (body must start on the next line after the opening '''). This is valid Apex and deploys successfully, but PMD's Apex frontend (summit-ast / apex-parser) throws a ParseException, so the file is skipped and no Apex rules run against it.
Observed when analyzing a class that declares a constant like:
private static final String JSON = '''
{
"Id": "001xx000003DGb0AAG"
}''';Error location points at the opening multiline string. The parser appears to treat the content as something other than a string literal (mismatched input expecting operators / ; / . / etc.).
Note: PMD 7.25.0 already ships apex-parser 5.0.0, but still fails with summit-ast 2.4.0 — so the gap may be in Summit AST handling of the multiline string token, not only the lexer.
Related Summer '26 APIs such as String.template(Map<String, Object>) may also need grammar/AST support, but the hard failure here is specifically on the multiline string literal itself.
Exception Stacktrace:
ParseException: Parse exception: com.google.summit.SummitAST$ParseException: Failed to parse MultilineStringRepro.cls:
Syntax error at 3:44: mismatched input ''\n {\n "Id": "001xx000003DGb0AAG",\n "Name": "Acme"\n }'' expecting {'instanceof', '[', ';', ',', '.', '=', '>', '<', '?.', '?', '==', '===', '!=', '<>', '!==', '&&', '||', '??', '++', '--', '+', '-', '*', '/', '&', '|', '^', '+=', '-=', '*=', '/=', '&=', '|=', '^=', '<<=', '>>=', '>>>='}
Code Sample demonstrating the issue:
@IsTest
public class MultilineStringRepro {
private static final String PAYLOAD = '''
{
"Id": "001xx000003DGb0AAG",
"Name": "Acme"
}''';
}(Optional fuller sample that also uses .template():)
@IsTest
public class MultilineStringTemplateRepro {
private static final String PAYLOAD = '''
{
"Id": "${RECORD_ID}",
"Name": "${RECORD_NAME}"
}''';
public static String build(String id, String name) {
return PAYLOAD.template(
new Map<String, Object>{
'RECORD_ID' => id,
'RECORD_NAME' => name
}
);
}
}Steps to reproduce:
- Save the minimal sample above as
MultilineStringRepro.cls. - Run PMD against it:
- CLI:
pmd check -d MultilineStringRepro.cls -R category/apex/bestpractices.xml -f text - or Salesforce Code Analyzer:
sf code-analyzer run --workspace MultilineStringRepro.cls --rule-selector pmd
- CLI:
- Observe the
SummitAST$ParseException/ mismatched input on the'''...'''literal; the file is not analyzed.
Running PMD through: CLI
- Reproduced with PMD CLI 7.25.0 (
apex-parser5.0.0,summit-ast2.4.0) - Also with
@salesforce/plugin-code-analyzer5.12.0 → PMD 7.23.0 - Also with
@salesforce/sfdx-scanner4.7.0 → PMD 7.6.0 - JDK: OpenJDK 21.0.3 (Temurin)
- OS: macOS 26.5.2 (Darwin 25.5.0, arm64)
Expected: PMD parses Apex Summer '26 multiline string literals and analyzes the file normally.
Actual: Parse failure; file skipped with the exception above.
Activity
[-][apex][/-][+][apex] ParseException on Summer '26 multiline string literals ('''...''')[/+]adangel commentedon Jul 17, 2026
Thanks for reporting. This will be fixed with #6862
[doc] Update release notes (pmd#6887)
[apex] Fix #6478: Bump apex-parser from 5.0.0 to 5.1.0 (#6862)