15.11.4
Runtime Evaluation of Method Invocation
EXPRESSIONS
( 15.11.3), then this is the method to be invoked, and the procedure terminates.
(We note that as part of the loading and linking process that the virtual machine
checks that an overriding method is at least as accessible as the overridden
method; an
IncompatibleClassChangeError
occurs if this is not the case.)
2. Otherwise, if
S
is not
T
, this same lookup procedure is performed using the
superclass of
S
; whatever it comes up with is the result of this lookup.
This procedure will find a suitable method when it reaches class
T
, because other
wise an
IllegalAccessError
would have been thrown by the checks of the pre
vious section 15.11.4.3.
We note that the dynamic lookup process, while described here explicitly, will
often be implemented implicitly, for example as a side effect of the construction
and use of per class method dispatch tables, or the construction of other per class
structures used for efficient dispatch.
15.11.4.5
Create Frame, Synchronize, Transfer Control
A method
m
in some class
S
has been identified as the one to be invoked.
Now a new
activation frame
is created, containing the target reference (if any)
and the argument values (if any), as well as enough space for the local variables
and stack for the method to be invoked and any other bookkeeping information
that may be required by the implementation (stack pointer, program counter, refer
ence to previous activation frame, and the like). If there is not sufficient memory
available to create such an activation frame, an
OutOfMemoryError
is thrown.
The newly created activation frame becomes the current activation frame. The
effect of this is to assign the argument values to corresponding freshly created
parameter variables of the method, and to make the target reference available as
this
, if there is a target reference.
If the method
m
is a
native
method but the necessary native, implementation
dependent binary code has not been loaded ( 20.16.14, 20.16.13) or otherwise
cannot be dynamically linked, then an
UnsatisfiedLinkError
is thrown.
If the method
m
is not
synchronized
, control is transferred to the body of the
method
m
to be invoked.
If the method
m
is
synchronized
, then an object must be locked before the
transfer of control. No further progress can be made until the current thread can
obtain the lock. If there is a target reference, then the target must be locked; other
wise the
Class
object for class
S
, the class of the method
m
, must be locked. Con
trol is then transferred to the body of the method
m
to be invoked. The object is
automatically unlocked when execution of the body of the method has completed,
whether normally or abruptly. The locking and unlocking behavior is exactly as if
the body of the method were embedded in a
synchronized
statement ( 14.17).
336
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