Java Reference
In-Depth Information
If the method being invoked is a variable arity method m , it necessarily has n > 0 formal
parameters. The final formal parameter of m necessarily has type T [] for some T , and m is
necessarily being invoked with k ≥ 0 actual argument expressions.
If m is being invoked with k n actual argument expressions, or, if m is being invoked with
k = n actual argument expressions and the type of the k 'th argument expression is not as-
signment compatible with T [] , then the argument list ( e 1 , ..., e n-1 , e n , ..., e k ) is evaluated as
if it were written as ( e 1 , ..., e n-1 , new | T [] | { e n , ..., e k } ), where | T [] | denotes the erasure (§ 4.6 )
of T [] .
The preceding paragraphs are crafted to handle the interaction of parameterized types
and array types that occurs in a Java Virtual Machine with erased generics. Namely,
if the element type T of the variable array parameter is non-reifiable, e.g. List<String> ,
then special care must be taken with the array creation expression (§ 15.10 ) because
the created array's element type must be reifiable. By erasing the array type of the
final expression in the argument list, we are guaranteed to obtain a reifiable element
type. Then, since the array creation expression appears in a method invocation con-
text, an unchecked conversion (§ 5.1.9 ) is possible from the array type with reifiable
element type to an array type with non-reifiable element type, specifically that of the
variable arity parameter. A Java compiler is required by § 5.1.9 to give a compile-time
unchecked warning at this conversion. Oracle's reference implementation of a Java
compiler identifies the unchecked warning here as a more informative unchecked gen-
eric array creation .
The argument expressions (possibly rewritten as described above) are now evaluated to
yield argument values . Each argument value corresponds to exactly one of the method's n
formal parameters.
The argument expressions, if any, are evaluated in order, from left to right. If the evaluation
of any argument expression completes abruptly, then no part of any argument expression to
its right appears to have been evaluated, and the method invocation completes abruptly for
the same reason. The result of evaluating the j 'th argument expression is the j 'th argument
value, for 1 ≤ j n . Evaluation then continues, using the argument values, as described be-
low.
15.12.4.3. Check Accessibility of Type and Method
Let C be the class containing the method invocation, and let T be the qualifying type of the
method invocation (§ 13.1 ) , and let m be the name of the method as determined at compile
time (§ 15.12.3 ) .
Search WWH ::




Custom Search