EXPRESSIONS
Compile Time Step 2: Determine Method Signature
15.11.2
15.11.2 Compile Time Step 2: Determine Method Signature
The hand writing experts were called upon for their opinion of the signature . . .
Agatha Christie,
The Mysterious Affair at Styles
(1920), Chapter 11
The second step searches the class or interface determined in the previous step for
method declarations. This step uses the name of the method and the types of the
argument expressions to locate method declarations that are both
applicable
and
accessible
, that is, declarations that can be correctly invoked on the given argu
ments. There may be more than one such method declaration, in which case the
most specific
one is chosen. The descriptor (signature plus return type) of the most
specific method declaration is one used at run time to do the method dispatch.
15.11.2.1
Find Methods that are Applicable and Accessible
A method declaration is
applicable
to a method invocation if and only if both of
the following are true:
The number of parameters in the method declaration equals the number of
argument expressions in the method invocation.
The type of each actual argument can be converted by method invocation con
version ( 5.3) to the type of the corresponding parameter. Method invocation
conversion is the same as assignment conversion ( 5.2), except that constants
of type
int
are never implicitly narrowed to
byte
,
short
, or
char
.
The class or interface determined by the process described in 15.11.1 is
searched for all method declarations applicable to this method invocation; method
definitions inherited from superclasses and superinterfaces are included in this
search.
Whether a method declaration is
accessible
to a method invocation depends
on the access modifier (
public
, none,
protected
, or
private
) in the method
declaration and on where the method invocation appears.
If the class or interface has no method declaration that is both applicable and
accessible, then a compile time error occurs.
In the example program:
public class Doubler {
static int two() { return two(1); }
private static int two(int i) { return 2*i; }
}
325
footer
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