Java Reference
In-Depth Information
Then let S i = F i [ R 1 = U 1 ,..., R p = U p ] (1 ≤ i n ) be the types inferred for the formal
parameters of m .
• Otherwise, let S 1 ... S n (where n k +1) be the types of the formal parameters of m .
The method m is an applicable variable-arity method if and only if all of the following
conditions hold:
• For 1 ≤ i < n , the type of e i , A i , can be converted by method invocation conversion
to S i .
• If k n , then for n i k , the type of e i , A i , can be converted by method invocation
conversion to the component type of S n .
• If k != n , or if k = n and A n cannot be converted by method invocation conversion
to S n [] , then the type which is the erasure (§ 4.6 ) of S n is accessible at the point of
invocation.
• If m is a generic method as described above, then U l <: B l [ R 1 = U 1 ..., R p = U p ] (1 ≤ l
p ).
If no applicable variable arity method is found, a compile-time error occurs.
Otherwise, the most specific method (§ 15.12.2.5 ) is chosen among the applicable variable-
arity methods.
15.12.2.5. Choosing the Most Specific Method
If more than one member method is both accessible and applicable to a method invocation,
it is necessary to choose one to provide the descriptor for the run-time method dispatch.
The Java programming language uses the rule that the most specific method is chosen.
The informal intuition is that one method is more specific than another if any invocation
handled by the first method could be passed on to the other one without a compile-time
type error.
One fixed-arity member method named m is more specific than another member method of
the same name and arity if all of the following conditions hold:
• The declared types of the parameters of the first member method are T 1 , ..., T n .
• The declared types of the parameters of the other method are U 1 , ..., U n .
• If the second method is generic, then let R 1 ... R p ( p ≥ 1) be its type parameters, let
B l be the declared bound of R l (1 ≤ l p ), let A 1 ... A p be the type arguments in-
Search WWH ::




Custom Search