|Check your Java with Error Prone|
|Written by Nikos Vaggalis|
|Monday, 24 October 2022|
Error Prone is a new Java compiler plugin created by Google which checks your code for common errors at compile-time. Not does only Error Prone identify issues but suggests their fixes too by analyzing the code’s abstract syntax tree (AST).
An example from the official documentation will make its use clear :
This incompatibility is an example of a bug pattern that Error Prone is looking for. It comes with many default such patterns, for instance :
The treats do not stop here though. You can also create your own Bug patterns although not a straightforward endeavor since you need to use Error Prone's api and interact with the code's AST.
Recognizing the difficulty, Google released another tool that ships with Error Prone called Refaster. Refaster is a tool that refactors your code using before-and-after templates. Once you write these templates, you compile them into .refaster files, then use the Error Prone compiler to refactor your code according to those rules. Refaster then scans for code that matches the before-template which replaces with the code found in the after-template.
Error Prone supports Java 8, 11 and 17 and can be used with Maven, Bazel, Ant and Gradle.
or email your comment to: email@example.com
|Last Updated ( Monday, 24 October 2022 )|