为什么不能@SafeVarags在最后类被应用到实例方法? [英] Why can't @SafeVarags be applied to instance methods in a final class?

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

问题描述

文档> SafeVarargs ,在 @SafeVarargs 注释只能适用于那些构造函数或可变参数数量方法或者静态最后。这是,<一个href=\"http://aruld.info/annotation-type-to-reduce-varargs-warnings-available-in-b123-java-7-coin-minting-done/\"相对=nofollow>我已阅读,以消除注释的继承问题;也就是说,在方法注解只允许如果该方法不能被重写。显然,构造,静态方法,以及最后方法不能被重写。但是,也不能最后一类的私人方法或方法有人抱怨了解无法指定 @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;看到 http://openjdk.java.net/jeps​​/213

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆