Skip to content

[apex] ParseException on Summer '26 multiline string literals ('''...''') #6887

Closed

Description

@ankit-swami

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:

  1. Save the minimal sample above as MultilineStringRepro.cls.
  2. 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
  3. 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-parser 5.0.0, summit-ast 2.4.0)
  • Also with @salesforce/plugin-code-analyzer 5.12.0 → PMD 7.23.0
  • Also with @salesforce/sfdx-scanner 4.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

  1. added
    a:bug
    on Jul 17, 2026
  2. changed the title [-][apex][/-] [+][apex] ParseException on Summer '26 multiline string literals ('''...''')[/+] on Jul 17, 2026
  3. adangel commented on Jul 17, 2026

    @adangel
    Member

    Thanks for reporting. This will be fixed with #6862

  4. added this to the 7.27.0 milestone on Jul 17, 2026
  5. added a commit that references this issue on Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions