Commons Annotations

In the previous post Tom pointed to an article discussing the use of some EJB 3.0 annotations in JSF applications: Using EJB Annotations Outside of EJB. The annotations discussed are @PostConstruct and @PreDestroy. The first annotation indicates a method to be called during creation, the other indicates a method to be called during destruction.

His post didn’t mention another interesting topic discussed: Common Annotations (JSR-250). This JSR aims to create a library with generally usable annotations. According to Ed Burns, the annotations @PostConstruct and @PreDestroy, should be part of Commons Annotations.

Commons Annotations contains some interesting annotations, as mentioned in this article on TSS: JSR 250: Common Annotations for the Java Platform in early draft. For example, the annotation @Generated, which indicates that the object or class was not hand-written.

I’m currenlty working with a lot of generated code: some generated using castor, some using JDeveloper’s visual swing editor, some using JDeveloper’s BC4J wizards. The @Generated annotation could be useful to indicate to tools like PMD, FindBugs and Checkstyle that the code does not need to be inspected. I’m sorry to say, but the code generated by JDeveloper causes these tools to generate a lot of warnings. Fortunately, most of the issues are no big deal: non standard naming, hard coded numbers, etc.