15.11.1
Compile Time Step 1: Determine Class or Interface to Search
EXPRESSIONS
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 possibil 
ity of instance method overriding.
Determining the method that will be invoked by a method invocation expres 
sion involves several steps. The following three sections describe the compile 
time processing of a method invocation; the determination of the type of the
method invocation expression is described in  15.11.3.
15.11.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 methods of that name. There are several cases to consider, depend 
ing on the form that precedes the left parenthesis, as follows:
If the form is
MethodName
, then there are three subcases:
N
If it is a simple name, that is, just an
Identifier
, then the name of the method
is the
Identifier
 and the class or interface to search is the one whose declara 
tion contains the method invocation.
N
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.
N
In all other cases, the qualified name has the form
FieldName
.
Identifier
;
then the name of the method is the
Identifier
 and the class or interface to
search is the declared type of the field named by the
FieldName
.
If the form is
Primary
.
Identifier
, then the name of the method is the
Identifier
and the class or interface to be searched is the type of the
Primary
expression.
If the form is
super .
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. A compile time error occurs if such a method
invocation occurs in an interface, or in the class
Object
, or in a
static
method, a static initializer, or the initializer for a
static
 variable. It follows
that a method invocation of this form may appear only in a class other than
Object
, and only in the body of an instance method, the body of a construc 
tor, or an initializer for an instance variable.
324






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved