JSR305 vs. JSR308 (Java Type Anotations) - Which is going to be the standard?

只愿长相守 提交于 2019-12-09 04:37:42

问题


There seem to be two different JSRs for annotations.

JSR-305: Annotations for Software Defect Detection (additional resource)
JSR-308: Annotations on Java Types (additional resource)

Both seem to be oriented towards static code analysis.

Do you know:

  • which of the both is going to be either in Java SE 7 or Java EE 6?
  • how "stable" is each JSR?
  • does the one supersedes (or obsoletes) the other?

回答1:


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

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.




回答2:


According to this document, last updated on 2010-09-19, JSR 308 is "Deferred to JDK 8 or later": http://openjdk.java.net/projects/jdk7/features/




回答3:


For future readers, JSR 308 is being integrated into Java 7. Some of its changes have already been pushed to the public betas of Java 7. JSR305 however didn't make the cut.



来源:https://stackoverflow.com/questions/1476757/jsr305-vs-jsr308-java-type-anotations-which-is-going-to-be-the-standard

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!