Java Reference
In-Depth Information
15.12.3. Compile-Time Step 3: Is the Chosen Method Appropriate?
If there is a most specific method declaration for a method invocation, it is called the
compile-time declaration for the method invocation.
If the method invocation has, before the left parenthesis, a MethodName of the form Iden-
tifier , and the compile-time declaration is an instance method, then:
• If the method invocation occurs in a static context (§ 8.1.3 ), then a compile-time er-
ror occurs.
The reason is that a method invocation of this form cannot be used to invoke
an instance method in places where this 15.8.3 ) is not defined.
• Otherwise, let C be the innermost enclosing class of which the compile-time de-
claration is a member.
If the invocation is not directly enclosed by C or an inner class of C , then a
compile-time error occurs.
If the method invocation has, before the left parenthesis, a MethodName of the form
TypeName . Identifier , or if the method invocation, before the left parenthesis, has the form
TypeName . NonWildTypeArguments Identifier , then the compile-time declaration must be
static , or a compile-time error occurs.
The reason is that a method invocation of this form does not specify a reference to an
object that can serve as this within the instance method.
If the method invocation has, before the left parenthesis, the form super . NonWildTypeAr-
guments opt Identifier , then:
• If the compile-time declaration is abstract , a compile-time error occurs.
• If the method invocation occurs in a static context, a compile-time error occurs.
If the method invocation has, before the left parenthesis, the form ClassName . super .
NonWildTypeArguments opt Identifier , then:
• If the compile-time declaration is abstract , a compile-time error occurs.
• If the method invocation occurs in a static context, a compile-time error occurs.
• Otherwise, let C be the class denoted by ClassName .
If the invocation is not directly enclosed by C or an inner class of C , then a
compile-time error occurs.
Search WWH ::




Custom Search