Skip to content

[java] Huge max-k in d=39 classBodyDeclaration while parsing ManyStringsConcat.java #4624

@kaby76

Description

@kaby76

The ManyStringsConcat.java example brings to light a large max-k when parsing a classBodyDeclaration for the input starting at @ApiModelProperty(value.... The decision that AdaptivePredict() is trying to find is d=39.

Image

The definition of classBodyDeclaration, which is loosely derived from the JLS 24, is the following.

classBodyDeclaration
: ';'
| STATIC? block
| modifier* memberDeclaration
;

The parser requires 3611 tokens to resolve the decision, and accounts for the majority of the time to parse the file.

Reading the source code of the javac parser, we see that this is not the grammar that the parser implements.

https://github.com/openjdk/jdk/blob/166ef5e7b1c6d6a9f0f1f29fedb7f65b94f53119/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java#L4721-L4782

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions