There is somewhat a similar question but here the scenario is different.
You are required to make a method final
if you want to use @SafeVarags
as in:
@SafeVarags
public final void myMethod(Whatever... args)
{
// code here
}
OK, fine. But then you are required to make the method final even in this situation:
// Class itself is final...
public final class MyClass
{
// ...
@SafeVarags
public void myMethod(Whatever... args) // COMPILE ERROR!
{
// code here
}
}
Why isn't the fact that the class itself is final enough for the compiler? Is this because of some obscure possible "shoot-yourself-in-the-foot" reflection?