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.

15.12.2 Compile-Time Step 2: Determine Method Signature EXPRESSIONS<br />

450<br />

15.12.2.6 Method Result and Throws Types<br />

• <strong>The</strong> result type of the chosen method is determined as follows:<br />

◆ If the method being invoked is declared with a return type of void, then the<br />

result is void.<br />

◆ Otherwise, if unchecked conversion was necessary for the method to be<br />

applicable then the result type is the erasure (§4.6) of the method’s declared<br />

return type.<br />

◆ Otherwise, if the method being invoked is generic, then for 1 ≤i≤n, let Fi be the formal type parameters of the method, let Ai be the actual type arguments<br />

inferred for the method invocation, and let R be the declared return<br />

type of the method being invoked. <strong>The</strong> result type is obtained by applying<br />

capture conversion (§5.1.10) to R[F1 := A1, ..., Fn := An]. ◆ Otherwise, the result type is obtained by applying capture conversion<br />

(§5.1.10) to the type given in the method declaration.<br />

<strong>The</strong> exception types of the throws clause of the chosen method are determined as<br />

follows:<br />

• If unchecked conversion was necessary for the method to be applicable then<br />

the throws clause is composed of the erasure (§4.6) of the types in the<br />

method’s declared throws clause.<br />

• Otherwise, if the method being invoked is generic, then for 1 ≤i≤n, let Fi be<br />

the formal type parameters of the method, let Ai be the actual type arguments<br />

inferred for the method invocation, and let Ej, 1 ≤ j ≤m<br />

be the exception<br />

types declared in the throws clause of the method being invoked. <strong>The</strong> throws<br />

clause consists of the types to Ej[F1 := A1, ..., Fn := An]. DRAFT<br />

• Otherwise, the type of the throws clause is the type given in the method declaration.<br />

A method invocation expression can throw an exception type E iff either:<br />

• <strong>The</strong> method to be invoked is of the form Primary.Identifier and the Primary<br />

expression can throw E; or<br />

• Some expression of the argument list can throw E; or<br />

• E is listed in the throws clause of the type of method that is invoked.

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

Saved successfully!

Ooh no, something went wrong!