JSR305与JSR308(Java类型Anotations) - 哪个将成为标准? [英] JSR305 vs. JSR308 (Java Type Anotations) - Which is going to be the standard?

查看:432
本文介绍了JSR305与JSR308(Java类型Anotations) - 哪个将成为标准?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注释似乎有两种不同的JSR。

There seem to be two different JSRs for annotations.

JSR- 305:软件缺陷检测注释 (其他资源)

JSR -308:Java类型的注释 (其他资源)

两者似乎都面向静态代码分析。

Both seem to be oriented towards static code analysis.

您知道吗:


  • 这两者中的哪一个将在Java SE 7或Java EE 6中?

  • 如何稳定是每个JSR?

  • 是否取代(或废弃)另一个?

推荐答案

我可以回答你的上一个问题。它们不是同一件事。 305是关于您可以放置​​它们的新注释,这有助于通过合同系统提供对设计的编程可见性。因此,如果某个方法不应返回null,或者某个方法应该永远不会收到空参数,则可以告诉系统分析注释以在这段代码中查找这个特定情况。

I can answer your last question. They are not the same thing. 305 is about new annotations where you can already put them, which can help provide programmatic visibility into a design by contract system. So that if a certain method is supposed to not return null, or if a certain method is supposed to never receive a null parameter, it is possible to tell the system analyzing the annotations to look out for this specific case at this piece of code.

308是关于能够注释更多内容的,例如泛型参数和类型转换。我想这是一个主要的用途是能够抑制特定类型转换的警告,而不必为此目的声明一个局部变量。 @SuppressWarnings注释已经存在(而JSR-305希望定义新注释),但在JSR-308中它可以应用于更多情况。

308 is about being able to annotate more things, such as a generic parameter and a type cast. I imagine a primary use for that is to be able to suppress warning on a specific type cast, instead of having to declare a local variable for that purpose. The @SuppressWarnings annotation already exists (whereas JSR-305 would look to define new ones), but in JSR-308 it could be applied to more cases.

根据<一个href =http://tech.puredanger.com/java7 =noreferrer>这个 308将成为Java7的一部分,这意味着它很稳定。 JSR-305不在列表中,所以看起来它不会像Java7那样。

According to this 308 will be part of Java7, which would imply it is quite well along to being stable. JSR-305 isn't on the list, so it doesn't look like it will make it to Java7.

这篇关于JSR305与JSR308(Java类型Anotations) - 哪个将成为标准?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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