10.12.2012 Views

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

EXPRESSIONS Runtime Evaluation of Method Invocation 15.12.4<br />

expression is not assignment compatible with T[], then the argument list (e1, ... ,<br />

en-1, en, ...ek) is evaluated as if it were written as (e1, ..., en-1, new T[]{en, ..., ek}). <strong>The</strong> argument expressions (possibly rewritten as described above) are now<br />

evaluated to yield argument values. Each argument value corresponds to exactly<br />

one of the method’s n formal parameters.<br />

<strong>The</strong> argument expressions, if any, are evaluated in order, from left to right. If<br />

the evaluation of any argument expression completes abruptly, then no part of any<br />

argument expression to its right appears to have been evaluated, and the method<br />

invocation completes abruptly for the same reason.<strong>The</strong> result of evaluating the jth<br />

argument expression is the jth argument value, for 1 ≤ j≤n. Evaluation then continues,<br />

using the argument values, as described below.<br />

15.12.4.3 Check Accessibility of Type and Method<br />

Let C be the class containing the method invocation, and let T be the qualifying<br />

type of the method invocation (§13.1), and m be the name of the method, as determined<br />

at compile time (§15.12.3). An implementation of the <strong>Java</strong> programming<br />

language must insure, as part of linkage, that the method m still exists in the type<br />

T. If this is not true, then a NoSuchMethodError (which is a subclass of IncompatibleClassChangeError)<br />

occurs. If the invocation mode is interface, then<br />

the implementation must also check that the target reference type still implements<br />

the specified interface. If the target reference type does not still implement the<br />

interface, then an IncompatibleClassChangeError occurs.<br />

<strong>The</strong> implementation must also insure, during linkage, that the type T and the<br />

method m are accessible. For the type T:<br />

• If T is in the same package as C, then T is accessible.<br />

• If T is in a different package than C, and T is public, then T is accessible.<br />

• If T is in a different package than C, and T is protected, then T is accessible<br />

if and only if C is a subclass of T.<br />

DRAFT<br />

For the method m:<br />

• If m is public, then m is accessible. (All members of interfaces are public<br />

(§9.2)).<br />

• If m is protected, then m is accessible if and only if either T is in the same<br />

package as C, or C is T or a subclass of T.<br />

• If m has default (package) access, then m is accessible if and only if T is in the<br />

same package as C.<br />

475

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!