Java 2026-07

Source: java/java/JavaParser.g4 @ 7d16f6dd457301340d0ae11e7d9d03269f682afd (7d16f6d) / antlr4 antlr4-parser-v1 / 2026-07-12

These diagrams describe a parser grammar, rather than the complete language specification. Lexer state and semantic checks may impose additional restrictions.

This is an upstream ANTLR grammar snapshot. Its date identifies the grammar revision, rather than a language release.

BSD-3-Clause

Readable Original grammar

compilationUnit

modularCompulationUnit

packageDeclaration

importDeclaration

typeDeclaration

modifier

classOrInterfaceModifier

variableModifier

classDeclaration

typeParameters

typeParameter

typeBound

enumDeclaration

enumConstants

enumConstant

enumBodyDeclarations

interfaceDeclaration

classBody

interfaceBody

classBodyDeclaration

memberDeclaration

methodDeclaration

methodBody

typeTypeOrVoid

genericMethodDeclaration

genericConstructorDeclaration

constructorDeclaration

compactConstructorDeclaration

fieldDeclaration

interfaceBodyDeclaration

interfaceMemberDeclaration

constDeclaration

constantDeclarator

interfaceMethodDeclaration

interfaceMethodModifier

genericInterfaceMethodDeclaration

interfaceCommonBodyDeclaration

variableDeclarators

variableDeclarator

variableDeclaratorId

variableInitializer

arrayInitializer

classType

packageName

typeArgument

qualifiedNameList

formalParameters

receiverParameter

formalParameterList

formalParameter

lambdaLVTIList

lambdaLVTIParameter

qualifiedName

literal

integerLiteral

floatLiteral

altAnnotationQualifiedName

annotation

annotationFieldValues

annotationFieldValue

annotationValue

elementValue

elementValueArrayInitializer

annotationTypeDeclaration

annotationTypeBody

annotationTypeElementDeclaration

annotationTypeElementRest

annotationMethodOrConstantRest

annotationMethodRest

annotationConstantRest

defaultValue

moduleDeclaration

moduleDirective

requiresModifier

recordDeclaration

recordHeader

recordComponentList

recordComponent

recordBody

block

blockStatement

localVariableDeclaration

identifier

typeIdentifier

localTypeDeclaration

statement

catchClause

catchType

finallyBlock

resourceSpecification

resources

resource

switchBlockStatementGroup

switchLabel

forControl

forInit

enhancedForControl

expressionList

methodCall

expression

pattern

componentPatternList

componentPattern

lambdaExpression

lambdaParameters

lambdaBody

primary

switchExpression

switchLabeledRule

guard

casePattern

switchRuleOutcome

classOrInterfaceType

creator

createdName

innerCreator

arrayCreatorRest

classCreatorRest

explicitGenericInvocation

typeArgumentsOrDiamond

nonWildcardTypeArgumentsOrDiamond

nonWildcardTypeArguments

typeList

typeType

primitiveType

typeArguments

superSuffix

explicitGenericInvocationSuffix

arguments

compilationUnit__1

compilationUnit__2

compilationUnit__3

modularCompulationUnit__1

packageDeclaration__1

importDeclaration__1

importDeclaration__2

typeDeclaration__1

typeDeclaration__2

classDeclaration__1

classDeclaration__2

classDeclaration__3

classDeclaration__4

typeParameters__1

typeParameter__1

typeParameter__2

typeParameter__3

typeBound__1

enumDeclaration__1

enumDeclaration__2

enumDeclaration__3

enumDeclaration__4

enumConstants__1

enumConstant__1

enumConstant__2

enumConstant__3

enumBodyDeclarations__1

interfaceDeclaration__1

interfaceDeclaration__2

interfaceDeclaration__3

classBody__1

interfaceBody__1

classBodyDeclaration__1

classBodyDeclaration__2

methodDeclaration__1

methodDeclaration__2

constructorDeclaration__1

compactConstructorDeclaration__1

interfaceBodyDeclaration__1

constDeclaration__1

constantDeclarator__1

interfaceMethodDeclaration__1

genericInterfaceMethodDeclaration__1

interfaceCommonBodyDeclaration__1

interfaceCommonBodyDeclaration__2

interfaceCommonBodyDeclaration__3

variableDeclarators__1

variableDeclarator__1

variableDeclaratorId__1

arrayInitializer__1

arrayInitializer__2

arrayInitializer__3

classType__1

classType__2

classType__3

classType__4

classType__5

classType__6

classType__7

packageName__1

typeArgument__1

typeArgument__2

typeArgument__3

qualifiedNameList__1

formalParameters__1

formalParameters__2

formalParameters__3

receiverParameter__1

formalParameterList__1

formalParameter__1

formalParameter__2

formalParameter__3

lambdaLVTIList__1

lambdaLVTIParameter__1

qualifiedName__1

altAnnotationQualifiedName__1

annotation__1

annotationFieldValues__1

annotationFieldValues__2

annotationValue__1

annotationValue__2

annotationValue__3

elementValueArrayInitializer__1

elementValueArrayInitializer__2

elementValueArrayInitializer__3

annotationTypeBody__1

annotationTypeElementDeclaration__1

annotationTypeElementRest__1

annotationTypeElementRest__2

annotationTypeElementRest__3

annotationTypeElementRest__4

annotationTypeElementRest__5

annotationMethodRest__1

moduleDeclaration__1

moduleDeclaration__2

moduleDeclaration__3

moduleDirective__1

moduleDirective__2

moduleDirective__3

moduleDirective__4

moduleDirective__5

moduleDirective__6

recordDeclaration__1

recordDeclaration__2

recordHeader__1

recordComponentList__1

recordComponent__1

recordComponent__2

recordComponent__3

recordBody__1

block__1

localVariableDeclaration__1

localVariableDeclaration__2

localTypeDeclaration__1

localTypeDeclaration__2

statement__1

statement__2

statement__3

statement__4

statement__5

statement__6

statement__7

statement__8

statement__9

statement__10

statement__11

statement__12

statement__13

catchClause__1

catchType__1

resourceSpecification__1

resources__1

resource__1

resource__2

switchBlockStatementGroup__1

switchBlockStatementGroup__2

switchLabel__1

forControl__1

forControl__2

forControl__3

enhancedForControl__1

enhancedForControl__2

expressionList__1

methodCall__1

expression__1

expression__2

expression__3

expression__4

expression__5

expression__6

expression__7

expression__8

expression__9

expression__10

expression__11

expression__12

expression__13

expression__14

expression__15

expression__16

expression__17

pattern__1

pattern__2

pattern__3

componentPatternList__1

lambdaParameters__1

lambdaParameters__2

lambdaParameters__3

primary__1

switchExpression__1

switchLabeledRule__1

switchLabeledRule__2

switchLabeledRule__3

switchLabeledRule__4

switchLabeledRule__5

switchLabeledRule__6

switchRuleOutcome__1

creator__1

createdName__1

createdName__2

createdName__3

innerCreator__1

arrayCreatorRest__1

arrayCreatorRest__2

arrayCreatorRest__3

classCreatorRest__1

typeList__1

typeType__1

typeType__2

typeType__3

typeType__4

typeArguments__1

superSuffix__1

superSuffix__2

arguments__1

Keyboard shortcuts

/ focuses search. j and k move between rules. ? opens this help. Escape closes it.