SafeVarargs classfile encoding

Joe Darcy joe.darcy at Oracle.com
Fri Jan 21 10:50:06 PST 2011


Hi Rémi.

A few comments, in the entirety of the "jdk" repository, there were a 
total of five methods where it was appropriate to add this annotation, 
which is not a very high density!  For Coin, to keep the features small, 
we're avoiding JVM changes and defining a new attribute is a JVM changes 
of sorts.

The SafeVarargs information is needed in the class file in some fashion 
to so that compilers can know to omit unchecked warnings that would 
otherwise have to be emitted.  Additionally, having the information in 
the class file enables tools like findbugs to do additional checking on 
the operations of the SafeVarargs methods.

Using an annotation to store this information avoids the need to add a 
new core reflection API to access it, Method.isSafeVarargs, etc.

-Joe

Rémi Forax wrote:
> I wonder if encoding @SafeVarargs as a runtime annotation
> in the classfile is a good idea. A runtime visible annotation is fat.
>
> In my opinion, @SafeVarargs should be an annotation with
> retention SOURCE, translated by the compiler to an empty SafeVarargs 
> method attribute.
>
> Is there a use case where this annotation is needed at runtime ?
>
> Rémi
>
>   




More information about the coin-dev mailing list