Skip to content

[java] Annotated module declarations cause parse error #1842

@oowekyala

Description

@oowekyala

Module declarations may be annotated. Although the grammar explicitly tries to handle this,
the lookahead is not sufficient and when seeing an annotation, the TypeDeclaration branch is taken:

( LOOKAHEAD(2) TypeDeclaration() ( EmptyStatement() )* )*
[ LOOKAHEAD({isKeyword("open") || isKeyword("module") || getToken(1).kind == AT}) ModuleDeclaration() ( EmptyStatement() )* ]

This can be used as a test case:

@Deprecated(since = "11", forRemoval = true)
module jdk.pack {
}

Metadata

Metadata

Assignees

Labels

a:bugPMD crashes or fails to analyse a file.in:astAbout the AST structure or API, the parsing step

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions