15.13.1 Names

A name occurring in an expression may be, syntactically, an ExpressionName(§6.5). The meaning of such an ExpressionName depends on its form:

  • If it is a simple name, that is, just an Identifier, then there are two cases:
    • If the Identifier occurs within the scope of a parameter or local variable named by that same Identifier, then the type of the ExpressionName is the declared type of the parameter or local variable; moreover, the value of the ExpressionName is a variable, namely, the parameter or local variable itself.
    • Otherwise, the ExpressionName is treated exactly as if it had been the field access expression (§15.10): this.Identifier containing the keyword this(§15.7.2).
  • Otherwise, if it is a qualified name of the form PackageName.Identifier, then a compile-time error occurs.
  • Otherwise, if it is a qualified name of the form TypeName.Identifier, then it is refers to a static field of the class or interface named by the TypeName. A compile-time error occurs if TypeName does not name a class or interface. A compile-time error occurs if the class or interface named by TypeName does not contain an accessible static field named by the Identifier. The type of the ExpressionName is the declared type of the static field. The value of the ExpressionName is a variable, namely, the static field itself.
  • Otherwise, it is a qualified name of the form Ename.Identifier, where Ename is itself an ExpressionName, and the ExpressionName is treated exactly as if it had been the field access expression (§15.10): (Ename).Identifier