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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

15.12.3 Compile-Time Step 3: Is the Chosen Method Appropriate? EXPRESSIONS<br />

472<br />

parenthesis, has the form TypeName.NonWildTypeArguments Identifier, then<br />

the compile-time declaration should be static. If the compile-time declaration<br />

for the method invocation is for an instance method, then a compile-time<br />

error occurs. (<strong>The</strong> reason is that a method invocation of this form does not<br />

specify a reference to an object that can serve as this within the instance<br />

method.)<br />

• If the method invocation has, before the left parenthesis, the form<br />

super.NonWildTypeArgumentsopt Identifier, then:<br />

◆ If the method is abstract, a compile-time error occurs<br />

◆ If the method invocation occurs in a static context, a compile-time error<br />

occurs<br />

• If the method invocation has, before the left parenthesis, the form<br />

ClassName.super.NonWildTypeArgumentsopt Identifier, then:<br />

◆ If the method is abstract, a compile-time error occurs<br />

◆ If the method invocation occurs in a static context, a compile-time error<br />

occurs<br />

◆ Otherwise, let C be the class denoted by ClassName. If the invocation is not<br />

directly enclosed by C or an inner class of C, then a compile-time error<br />

occurs<br />

• If the compile-time declaration for the method invocation is void, then the<br />

method invocation must be a top-level expression, that is, the Expression in an<br />

expression statement (§14.8) or in the ForInit or ForUpdate part of a for<br />

statement (§14.14), or a compile-time error occurs. (<strong>The</strong> reason is that such a<br />

method invocation produces no value and so must be used only in a situation<br />

where a value is not needed.)<br />

<strong>The</strong> following compile-time information is then associated with the method<br />

invocation for use at run time:<br />

• <strong>The</strong> name of the method.<br />

• <strong>The</strong> qualifying type of the method invocation (§13.1).<br />

• <strong>The</strong> number of parameters and the types of the parameters, in order.<br />

• <strong>The</strong> result type, or void.<br />

• <strong>The</strong> invocation mode, computed as follows:<br />

DRAFT

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

Saved successfully!

Ooh no, something went wrong!