Skip to content

An Example

StefanMedeleanu edited this page Jun 30, 2016 · 1 revision

The following is a example of applying the tool on a null check from the FindBugs project:

  1. The initial null check:

  2. We performed the refactoring and the null check was replaced with a polymorphic call:

  3. The code from the null check was extracted in 2 new methods who were moved in the class representing the type of the variable and the class replacing the case when the variable was null:

  4. We ran the null finding algorithm and found two possible places where null should be replaced with an instance of the null class. We manually instantiate the variable in the first case:

  5. In the second case however, we observe that instantiating the field 'last' would be pointless since we are covered by the 'if' from the method 'isLastWild'.

Clone this wiki locally