The syntax A.classlooks like access to a field, but in fact it is the result of a special syntax rule in a context where normal access to fields is simply not allowed; those. where Ais the name of the class.
Here's what the grammar says in JLS:
Primary:
ParExpression
NonWildcardTypeArguments (
ExplicitGenericInvocationSuffix | this Arguments)
this [Arguments]
super SuperSuffix
Literal
new Creator
Identifier { . Identifier }[ IdentifierSuffix]
BasicType {[]} .class
void.class
Note that for fieldor methodnot equivalent syntax.
( : b.field, JLS , b.field "field"... , . c.method , c. , , ...)
? , , Java / Field Method. (. * Java, .)
Java . Java , . . , .
, , . .
- , ?
, , , , , Class.forName("some horrible string") , - . / .
, , <type>.class , class . (IIRC, Java 1.1.)
* , :
- , .
- , , , ,
method field . b.field , . b.field /. field , , field, Java.c.method , , c. , c c, c.method method , c.