EXPRESSIONS
Runtime Evaluation of Method Invocation
15.11.4
For the method
m
:
If
m
is
public
, then
m
 is accessible. (All members of interfaces are
public
( 9.2)).
If
m
 is
protected
, then
m
 is accessible if and only if either
T
 is in the same
package as
C
, or
C
 is
T
 or a subclass of
T
.
If
m
 has default (package) access, then
m
 is accessible if and only if
T
 is in the
same package as
C
.
If
m
 is
private
, then
m
 is accessible if and only if and
C
 is
T
.
If either
T
 or
m
is not accessible, then an
IllegalAccessError
 occurs ( 12.3).
15.11.4.4
Locate Method to Invoke
The strategy for method lookup depends on the invocation mode.
If the invocation mode is
static
, no target reference is needed and overriding
is not allowed. Method
m
 of class
T
 is the one to be invoked.
Otherwise, an instance method is to be invoked and there is a target reference.
If the target reference is
null
, a
NullPointerException
 is thrown at this point.
Otherwise, the target reference is said to refer to a
target object
 and will be used as
the value of the keyword
this
 in the invoked method. The other four possibilities
for the invocation mode are then considered.
If the invocation mode is
nonvirtual
, overriding is not allowed. Method
m
 of
class
T
 is the one to be invoked.
Otherwise, the invocation mode is
interface
,
virtual
, or
super
, and over 
riding may occur. A
dynamic method lookup
is used. The dynamic lookup process
starts from a class
S
, determined as follows:
If the invocation mode is
interface
 or
virtual
, then
S
is initially the actual
run time class
R
 of the target object. If the target object is an array,
R
 is the
class
Object
. (Note that for invocation mode
interface
,
R
 necessarily
implements
T
; for invocation mode
virtual
,
R
 is necessarily either
T
 or a
subclass of
T
.)
If the invocation mode is
super
, then
S
 is initially the superclass of the class
C
 that contains the method invocation.
The dynamic method lookup uses the following procedure to search class
S
, and
then the superclasses of class
S
, as necessary, for method
m
.
1. If class
S
 contains a declaration for a method named
m
 with the same descriptor
(same number of parameters, the same parameter types, and the same return
type) required by the method invocation as determined at compile time
335






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