What jarnotator does in less than 1 minute
Last Updated on Friday, 27 August 2010 06:12 Written by jarnotator Thursday, 19 August 2010 09:33
NullPointerException-s still plague the java world. Commercial programs that throw such exceptions from time to time are unfortunately not so rare. It is here that jarnotator steps in to help addressing this problem. Described in what should amount to less than a minute worth of reading follows what jarnatotor does.
The jarnotator logic analyzes bytecode looking for specific patterns. In particular those related to nullness. Based on the observed patterns jarnotator will add jsr305 (see Web links) nullness related annotations like @javax.annotation.CheckForNull.
For instance if an explicit return null; statement is discovered the method bytecode will be annotated with @CheckForNull. By itself this will NOT influence the behaviour of the bytecode in any way. The annotation is however pickedup by the excellent findbugs (TM) (see Web links). If your code happens to call a @CheckForNull annotated method without perfoming a null-check findbugs (TM) will report this possible NullPointerException.
But jarnotator does not stop there. Annotation are not only put onto the methods. jarnotator can also propagate this constraint to other methods when necessary. If you already use jsr305 annotation you are in luck too. Not only can jarnotator discover missing annotation and propagate them. it can do the same for annotation add manually in your source code.
Possibly a few answers to question that my arise put in FAQ-style
- Q: Can it annotate interfaces?
- A: Yes, annotations applied to an interface implementation can be propagate to the interface.
- Q: Can it annotate abstract classes?
- A: Yes, annotations applied to an abstract method implementation can be propagate to the abstract parent.
- Q: Method m1() returns a call to the null-returning method m2() directly. Will m1() be annotated as well?
- A: Yes
- Q: Will the jar have a dependency on the jarnotator jar after it has been processed?
- A: No, not at all.
- Q: Will the jar have a dependency on the jsr305 jar after it has been processed?
- A: Possible. If the code is inspected with the Relfection API the jsr305 jar is needed. Probably the same for other annotation processing tool.
- Q: Will new runtime checks be inserted in the bytecode?
- A: No
- Q: Will the runtime performance degrade?
- A: No
- Q: Does jarnotator perform any bytecode optimization?
- A: No
Feed Display
| Linux Today |
| Linux Today News Service |
![]() |
|















