PROPOSAL: Simplified Varargs Method Invocation (Round II)

Joseph D. Darcy Joe.Darcy at Sun.COM
Tue Mar 17 15:46:13 PDT 2009


Bob Lee wrote:
> Simplified Varargs Method Invocation
>
> AUTHOR: Bob Lee
>
> OVERVIEW
>
> FEATURE SUMMARY: When a programmer tries to invoke a varargs (variable
> arity) method with a non-reifiable varargs type, the compiler currently
> generates an "unsafe operation" warning. This proposal moves the warning
> from the call site to the method declaration.
>   

The general contract when adding generics was "if your entire program 
compiles without unchecked warnings, you won't get heap pollution at 
runtime," heap pollution being where "a variable of parameterized type 
refers to an object that is not of that parameterized type" (JLSv3 
4.12.2.1).

While warning at the declaration site is fine for a lint-style warning, 
the use sites merit warnings too because of heap pollution.

Generics and arrays (including varags) simply do not play well together!

-Joe




More information about the coin-dev mailing list