While the Java grammar seems very accurately described in the JLS specifications, there are some specific cases that I cannot apply to the given definitions.
For example, if you accept the ClassInstanceCreationExpression rule in ClassInstanceCreationExpression Chapter 15.9, unskilled new expressions should look like this:
new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody]
Identifier is a standard Java identifier (mostly Java letters / numbers, no ).
How this definition applies to valid expressions, such as initializing static nested classes:
new C1.C2();
or initialization of classes corresponding to packages:
new java.lang.String("foo");
Given that points cannot be part of an Identifier ?
Note that in this definition from JLS7 to JLS8, the change was indicated, where JLS7 indicated, for unqualified new expressions:
new [TypeArguments] TypeDeclSpecifier [TypeArgumentsOrDiamond]( [ArgumentList] ) [ClassBody]
TypeDeclSpecifier defined as:
TypeDeclSpecifier: TypeName ClassOrInterfaceType . Identifier
allows unqualified new expressions for static nested classes and classes corresponding to the class.
lledr source share