tree: 6d68cbb0bc754f11b6c15cb1a1fef1ee496b646e [path history] [tgz]
  1. ant/
  2. lib/
  3. maven/
  4. nbproject/
  5. processor/
  6. test/
  7. tool/
  8. build.sh
  9. build.xml
  10. rat-exclusions.txt
  11. README.md
cmdline/README.md

Apache NetBeans Standalone Java Hints

This tool allows to run NetBeans Java code checker without the NetBeans IDE. This includes running the custom Java hints specified in META-INF/upgrade/*.hint.

Requirements

To Build

  • Apache NetBeans 20
  • JDK 11, JDK 17 and JDK 21
  • bash
  • Apache ant 1.9.9 or above
  • Apache Maven 3.3.9 or above

To Run

  • JDK 11-21

Building

Build using:

$ ant -DNETBEANS_PLATFORM=<path-to-NetBeans-20> -DJDK11=<path-to-JDK-11> -DJDK17=<path-to-JDK-17> -DJDK21=<path-to-JDK-21> build-and-test

The built product is in tool/build/jackpot.

Running

Run using:

$ jackpot <options> <files-to-inspect>

To get help on the options, run:

$ jackpot --help

Example

Consider this sample code:

package test;

public class Test {
    public void test(boolean b) {
        int i = 0;
        if (b)
            System.err.println("was true");
            assert (i = 1) == 1;
    }
}

It is possible to get a warning for the improper indentation like this:

$ jackpot --hint "Confusing indentation" <somedir>/src
<somedir>/src/test/Test.java:9: warning: [Confusing_indentation] Confusing indentation
            assert (i = 1) == 1;
            ^

Or a warning for the side-effects inside the assert:

$ jackpot --hint "Assert with side effects" <somedir>/src
<somedir>/src/test/Test.java:9: warning: [Assert_with_side_effects] Assert condition produces side effects
            assert (i = 1) == 1;
                    ^

All supported hints can be listed using:

$ jackpot --list

It is also possible to use a configuration file which enables multiple hints at once using:

$ jackpot --config-file <path-to-config-file> <path-to-sources-to-check>

The config file can be generated by the NetBeans IDE, using Project Properties/Hints, or similar ways.