简体   繁体   中英

Why can't @SafeVarags be applied to instance methods in a final class?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM