Celtique Project

Nit: Nullability Inference Tool

Frequently Asked Questions

What is the license of this software ?
This software is distributed under the GNU General Public License.
Which OS does it work under ?
It should works on Windows and any Unix system (including Linux, MacOS, etc.).
If the analysis says that there is no bug, can we trust it ?
Although it is pretty sure that there is no bug, the program does not analyze native methods so it is still possible to produce a NullPointerException without Nit knowing it. If there is no native method (and therefore no reflexion), then if Nit says there is no bug it is sure there is no bug.
Which Java features are handled ? And which one are not ?

Nit may be incorrect in the presence of native methods or reflexion. Nit assumes that native methods may return the null constant or object under initialization (this is conservative) but it also assumes that native methods do not modify any other object in the heap (it may lead to incorrect result, but Nit cannot work without this assumption).

Nit does not precisely handles:

  • static fields and arrays (Nit assumes they may contain anything);
  • jsr/ret op-codes (Nit may consider that all variables that are on the stack may contain anything ; note that those op-codes are not produced anymore with javac);
  • exception (Nit assumes a caught exception is non-null but may not be completely initialized);
  • Java assertions (they can be deactivated at run-time and therefore do not guaranty that no NullPointerException may be thrown).

Everything else should be handled quite precisely.

It is not precise enough. Is there a way to improve things ?

Yes, it is possible by modifying your source code. The basics are the followings.

  • Nit tracks precisely local variables.
  • Field annotations are determined at the end of the constructor (so if a field is not yet defined it will always be annotated at Nullable).

Here are some hints to adapt your code.

  • Initialized the fields in the corresponding constructors.
  • Save temporary data into local variables instead of fetching them repeatedly.
  • If you are sure a variable is non-null and Nit is not able to prove it, add a test and throw an exception in the else branch (I may modify Nit to do this with some annotations instead of some code but it needs some coding, tell me if you need it).
Last modification: 2009-09-23 18:10:52.000000000 +0200
This website uses Google Analytics