Why can't the annotation @SafeVarargs be applied to non-final instance methods?
If you declare @SafeVarargs, then you must be sure it is actually safe. If a method is non-final, it can be overridden in a subclass. That override might not be safe.
By requiring that the method is final, the developer can guarantee that the declaration he made (namely that its varargs use is safe) is actually always true (provided of course that the developer actually provided a safe varargs method), and that it wasn't actually broken by a subclass incorrectly reimplementing the method.
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