How to use FindBugs with NetBeans sources

This document describes how FindBugs is used during the development of NetBeans.

Running FindBugs locally

For every NetBeans module, you can run the findbugs check by typing:

cd your.module
ant findbugs
This will produce the findbugs report file in
and fails if at least one warning was discovered. No file is created if there is no problem in the tested module.

There is also a target in nbbuild to execute the test for all modules in a cluster at once:

ant -f nbbuild/build.xml findbugs-cluster
This produces the output files for each module with a problem in

Evaluating FindBugs warnings

The report containing FindBugs warnings can be viewed using the FindBugs UI. This tool can be downloaded from the FindBugs website: After installing FindBugs, you can run the tool using the
script in the bin directory. In the FindBugs UI, you may want to sort the issues by priority, by dragging the labels at the top left.

Suppressing warnings

In some cases, you may want to suppress a particular warning, rather than fix it. Always think twice about suppressing as FindBugs is usually right. If you really know it is a false warning you can do the following:

  1. Make sure your module uses the Common Annotations module (api.annotations.common).
  2. Find the id of the warning you want to suppress. Open the FindBugs report in a text editor, and find the <BugInstance> element for your warning. The value of the type attribute of this element is your warning id. The warning id is also displayed in FindBugs UI:
  3. Add the following annotation to the code (method, class, instance variable, local variable etc.) in which you want to suppress the warning:
    @org.netbeans.api.annotations.common.SuppressWarnings(value="your_warning_id", justification="Explanation why this is false warning")
  4. It is good to be consistent when justifying the same type of things.

Additional information

  • The SignatureTest also helps to maintain high quality of NetBeans code.
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo