I believe that the earlier you can do the bulk of your testing, the better. To most people this tends to mean automated *unit tests. To me, it means that and any other means of inspection I can throw at the codebase before it lands on my desk. Tools like FindBugs and Checkstyle are what really interest me these days but the problem inherit in them is that they can only check what the code tells them. To improve their effectiveness then, we need to teach the tools more about our code. JSR 305: Annotations for Software Defect Detection is an attempt to do just. The video explains how it is proposed that annotations will be used in Java 5 and newer to tell existing (and next-generation) tools about characteristics of the application that might not be readily obvious. It also goes into detail on how you would implement your own custom annotations, but I somewhat tuned out during that section; java developers might get value from it though. The notes I did take are below.

  • Annotations express design decisions that may be implicit, or described in documentation, but not easily available to tools
  • Many bugs can only be identified, or only localized, if you know something about what the code is supposed to do
  • Annotations added java 5
  • When documenting nullness
    • Want to document parameters, return values and fields
    • Argument to equals(Object)
    • If argument to equals is immediately dereferenced Should be able to say 3 things about a return value - Guarenteed to be non null
  • Null feasible (need to worry about whether they need to worry about having null)
  • Unknown nullness – no statement of design intent for this element

  • All the talk of naming annotations in a common way for tools seems like we’re entering a big semantic rabbit hole
  • The annotations essentially add an additional type system on top of the existing java type system
  • It’s a good to describe your information with details of the level of imprecision
  • Possabilities of occurance
    • Always
    • Never
    • Most are definitely not going to happen, but a small amount might
    • Maybe either
    • Most are definitely going to happen, but a small amount might not
    • unknown
  • You can set defaults annotations at the class and package level for cleaner code and to not change so much code (which might require some sort of sign-off
  • Annotations can also be inherited

</embed>

Direct link to video here