Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?
like image 886
ivan_ivanovich_ivanoff Avatar asked Sep 25 '09 11:09

ivan_ivanovich_ivanoff


3 Answers

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.

like image 112
Yishai Avatar answered Oct 19 '22 07:10

Yishai


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/

like image 31
Vishal Rao Avatar answered Oct 19 '22 09:10

Vishal Rao


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.

like image 36
notnoop Avatar answered Oct 19 '22 07:10

notnoop