views:

331

answers:

2

Hello!

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?
+3  A: 

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.

Yishai
So, practically JSR-308 is only an extensions to the language,while those checkers (which are discussed on the project's page), are optional and will not be available in the JDK), right?
ivan_ivanovich_ivanoff
It seems that way. The two proposals work together since they are most useful together (which is why the JSR-308 page is touting that kind of functionality). I don't have any authoritative information on what will or won't be in JDK7, but it seems that JSR-305 isn't making it, but I could well be wrong about that.
Yishai
+1  A: 

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.

notnoop
With JSR308, will Java7 provide a standard checker framework?
ivan_ivanovich_ivanoff
The checkers are being distributed at http://types.cs.washington.edu/jsr308 . There is a possibility that the JDK will bundle them, but no guarantees are given yet.
notnoop