Wiki Maven example fails with current Error Prone: missing --should-stop=ifError=FLOW and -XDaddTypeAnnotationsToSymbol=true

Open Beginner friendly
#2,058 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
documentation

Research direction

The issue identifies the Configuration wiki page’s Maven example and provides a working snippet plus the required JDK and JVM setup notes. Read the existing Maven section and compare it with the suggested flags and version requirements. Update the example and add the prerequisite notes; done when the instructions cover the reported JDK 21 build and point to Error Prone’s installation docs.

Written by the indexing model from the issue text.

Description

The Maven example on the Configuration wiki page pins Error Prone 2.23.0 and NullAway 0.10.15. When I raise the two versions to the current releases (Error Prone 2.51.0, NullAway 0.14.3) and build on JDK 21, compilation stops before any check runs. The example can't be used as it stands with any NullAway 0.13 or later either, because the changelog for 0.13.0 says NullAway "now requires a minimum of JDK 17 and Error Prone 2.36.0 to run".

Steps to reproduce

Wiki at 8743f3a. Maven 3.9.16, Oracle JDK 21.0.12, .mvn/jvm.config with the --add-exports and --add-opens lines from the Error Prone installation docs. src/main/java/com/example/Main.java:

package com.example;
public class Main {
  static void mainBug() { Object o = null; int h = o.hashCode(); }
}

pom.xml is the wiki example with AnnotatedPackages=com.example:

  1. As written (Error Prone 2.23.0, NullAway 0.10.15), mvn clean compile succeeds and reports [NullAway] dereferenced expression o is @Nullable.

  2. With error_prone_core 2.51.0 and nullaway 0.14.3, it fails:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project wiki: Fatal error compiling: The default --should-stop=ifError policy (INIT) is not supported by Error Prone, pass --should-stop=ifError=FLOW instead -> [Help 1]
    
  3. After adding <arg>--should-stop=ifError=FLOW</arg>, it fails on the next flag:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project wiki: Fatal error compiling: -XDaddTypeAnnotationsToSymbol=true is required by Error Prone on JDK 21 -> [Help 1]
    

    On JDK 25.0.4 this step succeeds: Error Prone requires the flag only on JDK 21 and earlier. The -XDaddTypeAnnotationsToSymbol requirement arrived in Error Prone 2.46.0.

  4. After adding <arg>-XDaddTypeAnnotationsToSymbol=true</arg> as well, the build succeeds on JDK 21.0.12 and on JDK 25.0.4 and reports [NullAway] dereferenced expression 'o' is @Nullable.

Expected behavior

The wiki example builds with the current Error Prone and NullAway releases on JDK 21, the oldest JDK current Error Prone runs on (on JDK 17.0.20 the build fails with UnsupportedClassVersionError: com/google/errorprone/ErrorProneJavacPlugin has been compiled by a more recent version of the Java Runtime (class file version 65.0)). Error Prone's own Maven example already carries both flags.

Suggested wiki text

The snippet from step 4, which I built on JDK 21.0.12 and 25.0.4:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.11.0</version>
        <configuration>
          <source>11</source>
          <target>11</target>
          <encoding>UTF-8</encoding>
          <compilerArgs>
            <arg>-XDcompilePolicy=simple</arg>
            <arg>--should-stop=ifError=FLOW</arg>
            <!-- required by Error Prone 2.46.0 and later when building on JDK 21 -->
            <arg>-XDaddTypeAnnotationsToSymbol=true</arg>
            <arg>-Xplugin:ErrorProne -XepOpt:NullAway:AnnotatedPackages=com.uber</arg>
          </compilerArgs>
          <annotationProcessorPaths>
            <path>
              <groupId>com.google.errorprone</groupId>
              <artifactId>error_prone_core</artifactId>
              <version>2.51.0</version>
            </path>
            <path>
              <groupId>com.uber.nullaway</groupId>
              <artifactId>nullaway</artifactId>
              <version>0.14.3</version>
            </path>
          </annotationProcessorPaths>
        </configuration>
      </plugin>
    </plugins>
  </build>

A sentence under it saying that Error Prone needs JDK 21 or later to run, and pointing to the Error Prone installation docs for the .mvn/jvm.config lines, would cover the other two prerequisites of the build.

Found while triaging #162, which asks for a separate addition to the same wiki section. I found no existing issue about the Maven example's versions or flags; #358 fixed a missing </plugins> in an earlier version of the snippet.

Dominant language
Java
Stars
4.1k
Forks
379
Avg merge
1d 2h
Merged PRs (30d)
106

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from uber/NullAway

All issues in uber/NullAway

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.