Java Reference
In-Depth Information
• The number of parameters and the types of the parameters, in order.
• The result type, or void .
• The invocation mode, computed as follows:
♦ If the compile-time declaration has the static modifier, then the invocation
mode is static .
♦ Otherwise, if the compile-time declaration has the private modifier, then the in-
vocation mode is nonvirtual .
♦ Otherwise, if the part of the method invocation before the left parenthesis is of
the form super . Identifier or of the form ClassName . super . Identifier , then the
invocation mode is super .
♦ Otherwise, if the compile-time declaration is in an interface, then the invoca-
tion mode is interface .
♦ Otherwise, the invocation mode is virtual .
If the compile-time declaration for the method invocation is not void , then the type of the
method invocation expression is the result type specified in the compile-time declaration.
15.12.4. Run-Time Evaluation of Method Invocation
At run time, method invocation requires five steps. First, a target reference may be com-
puted. Second, the argument expressions are evaluated. Third, the accessibility of the meth-
od to be invoked is checked. Fourth, the actual code for the method to be executed is loc-
ated. Fifth, a new activation frame is created, synchronization is performed if necessary,
and control is transferred to the method code.
15.12.4.1. Compute Target Reference (If Necessary)
There are several cases to consider, depending on which of the five productions for Meth-
odInvocation 15.12 ) is involved:
1. If the first production for MethodInvocation, which includes a MethodName , is in-
volved, then there are three subcases:
• If the MethodName is a simple name, that is, just an Identifier , then there are
two subcases:
♦ If the invocation mode is static , then there is no target reference.
♦ Otherwise, let T be the enclosing type declaration of which the method is a
member, and let n be an integer such that T is the n 'th lexically enclosing type
declaration (§ 8.1.3 ) of the class whose declaration immediately contains the
Search WWH ::




Custom Search