liveBook · Manning

Infer

As explained in 100 Java Mistakes and How to Avoid Them

Infer is a static analyzer that performs deep analysis of code to detect certain potential defects.

Infer is an advanced static analyzer for deep interprocedural analysis. It can find nontrivial potential NullPointerException problems that simpler, online nullity inference may miss. section 5.1.3

Use Infer when code spans multiple methods or includes unannotated and legacy components. Treat its findings as potential defects requiring review, rather than as proof that every flagged path fails. section 5.1.3

A nontrivial null path

A method may trim an input and return null for an empty result; downstream code that assumes a non-null return can create a potential NullPointerException. Infer targets this kind of cross-method nullity problem. section 5.1.3

How 100 Java Mistakes and How to Avoid Them covers it

How deep it goes
Performs deep interprocedural analysis, descending beyond limited online inference to identify nontrivial potential failures.
Examples
Uses methods with nullable returns and downstream dereferences as representative nullity-analysis cases.
What you can do after
Diagnose/debug potential NullPointerException paths across method boundaries.
How it connects
Connects static analysis with nullity annotations and NullPointerException prevention.

This explainer was generated by Manning's knowledge graph from the text of 100 Java Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.