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

ivan_ivanovich_ivanoff picture ivan_ivanovich_ivanoff · Sep 25, 2009 · Viewed 8.1k times · Source

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?

Answer

Yishai picture Yishai · Sep 25, 2009

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.