本文介绍了为什么不能@SafeVarags在最后类被应用到实例方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据文档> SafeVarargs ,在 @SafeVarargs 注释只能适用于那些构造函数或可变参数数量方法或者静态最后。这是,我已阅读,以消除注释的继承问题;也就是说,在方法注解只允许如果该方法不能被重写。显然,构造,静态方法,以及最后方法不能被重写。但是,也不能最后一类的私人方法或方法。 无法指定 @SafeVarargs私人方法,但。在一般情况下,<一href=\"https://www.google.com/search?q=%40safevarags+annotation+cannot+be+applied+to+non-final+instance+method&oq=%40safevarags+annotation+cannot+be+applied+to+non-final+instance+method\"相对=nofollow>没有人似乎真的不在乎。我缺少的东西吗?难道我抱怨的东西,没有任何实际的应用?还是...?

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... ?

推荐答案

这是安排固定在Java中9;看到。

This is scheduled to be fixed in Java 9; see http://openjdk.java.net/jeps/213 .

这篇关于为什么不能@SafeVarags在最后类被应用到实例方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 01:29