According to the documentation of SafeVarargs
, the @SafeVarargs
annotation can be applied only to constructors or variable arity methods that are either static
or final
. This is, I have read, to eliminate issues with annotation inheritance; that is to say, annotations on methods are only allowed if the method cannot be overridden. Clearly, constructors, static
methods, and final
methods cannot be overridden. However, neither can private
methods or methods in a final class
. Someone has complained about the inability to designate @SafeVarargs private
methods, but neither of these issues has been addressed. In general, no one really seems to care. Am I missing something? Am I complaining about something that doesn't have any practical applications? Or... ?
This is scheduled to be fixed in Java 9; see http://openjdk.java.net/jeps/213 .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With