Java Reference
In-Depth Information
((I)this).x=
0
Within class T3 , the expression super.x is treated as if it were:
((T2)this).x
Note that super.x is not specified in terms of a cast, due to difficulties around access to pro-
tected members of the superclass.
15.12. Method Invocation Expressions
A method invocation expression is used to invoke a class or instance method.
MethodInvocation:
MethodName ( ArgumentList opt )
Primary . NonWildTypeArguments opt Identifier ( ArgumentList opt )
super . NonWildTypeArguments opt Identifier ( ArgumentList opt )
ClassName . super . NonWildTypeArguments opt Identifier ( ArgumentList opt )
TypeName . NonWildTypeArguments Identifier ( ArgumentList opt )
The definition of ArgumentList from § 15.9 is repeated here for convenience:
ArgumentList:
Expression
ArgumentList , Expression
Resolving a method name at compile time is more complicated than resolving a field name
because of the possibility of method overloading. Invoking a method at run time is also
more complicated than accessing a field because of the possibility of instance method over-
riding.
Determining the method that will be invoked by a method invocation expression involves
several steps. The following three sections describe the compile-time processing of a meth-
od invocation; the determination of the type of the method invocation expression is de-
scribed in § 15.12.3 .
15.12.1. Compile-Time Step 1: Determine Class or Interface to Search
The first step in processing a method invocation at compile time is to figure out the name
of the method to be invoked and which class or interface to check for definitions of meth-
ods of that name. There are several cases to consider, depending on the form that precedes
the left parenthesis, as follows.
Search WWH ::




Custom Search