Java Reference
In-Depth Information
• If the form is
MethodName
, then there are three subcases:
♦ If it is a simple name, that is, just an
Identifier
, then the name of the method is
the
Identifier
.
If the
Identifier
appears within the scope (§
6.3
) of a visible method declaration
with that name, then:
If there is an enclosing type declaration of which that method is a member,
let
T
be the innermost such type declaration. The class or interface to search
is
T
.
Otherwise, the visible method declaration may be in scope due to one or
clarations. There is no class or interface to search, as the method to be in-
voked is determined later (§
15.12.2
).
♦ If it is a qualified name of the form
TypeName
.
Identifier
, then the name of the
method is the
Identifier
and the class to search is the one named by the
TypeName
.
If
TypeName
is the name of an interface rather than a class, then a compile-time
error occurs, because this form can invoke only
static
methods and interfaces
have no
static
methods.
♦ In all other cases, the qualified name has the form
FieldName
.
Identifier
.
The name of the method is the
Identifier
and the class or interface to search is
the declared type
T
of the field named by the
FieldName
, if
T
is a class or inter-
face type, or the upper bound of
T
if
T
is a type variable.
• If the form is
Primary
.
NonWildTypeArguments
opt
Identifier
, then the name of the
method is the
Identifier
.
Let
T
be the type of the
Primary
expression. The class or interface to be searched
is
T
if
T
is a class or interface type, or the upper bound of
T
if
T
is a type variable.
It is a compile-time error if
T
is not a reference type.
• If the form is
super .
NonWildTypeArguments
opt
Identifier
, then the name of the
method is the
Identifier
and the class to be searched is the superclass of the class
whose declaration contains the method invocation.
Let
T
be the type declaration immediately enclosing the method invocation. It is a
compile-time error if
T
is the class
Object
or
T
is an interface.