Preventing Bugs with pluggable type checking by Michael Ernst
- New Feature in Java 7
- The motivation of the presentation is to help people to design a type system to solve a specific problem
- Java 7 has a new annotation syntax: e.g. List <@NonNull String> strings; or myGraph = (@Immutable Graph) tmpGraph;
- Type Qualifiers improves documentation, find bugs in programs, guarantee the absence of errors and reduces the need for assertions and run-time checks
- Checkers are designed as compiler plug-ins (i.e. annotation processors) and use familiar messages; many checkers are being implementd in Java 7
- Michael said: "If you want to find some bugs in your code, Findbugs is ok. If you are a developer who cares, you'll want to find ALL your bugs, and this is the tool for that"
- It is possible to create your own type checking annotations, and he showed us how to write a quick one to avoid SQL injection in our code that access the database
- Michael showed some statistics comparing FindBugs and the new Java 7 type checking; type checking found 8 bugs (20000 LOC) and findBugs none; on the other hand, type chacking demanded 35 annotations to be written throughout the code
- It is said that annotations like these would clutter your code, but in my opinion it is a good trade-off for having a "bug-free" code
- Another interesting option that Type Checking offers, is that one can start doing the annotation of the code on a per-module or per-class basis, i.e. start with the most important parts of the code
No comments:
Post a Comment