Skip to content

Encountering NullArgumentForNonNullParameter when building testlib #8650

Description

@McDaMastR

Hello,

I'm attempting to port Guava 33.7.1 to MacPorts (a package manager for macOS), but am unable to build the guava-testlib module. Attempting to do so results in several errors of the following form.

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /[...]/guava-33.7.1/guava-testlib/src/com/google/common/collect/testing/google/BiMapPutTester.java:[99,22] [NullArgumentForNonNullParameter] Null is not permitted for parameter 'key' of method 'forcePut'.
[ERROR]     (see https://errorprone.info/bugpattern/NullArgumentForNonNullParameter)
[...]
[ERROR] /[...]/guava-33.7.1/guava-testlib/src/com/google/common/collect/testing/google/MultimapAsMapGetTester.java:[76,46] [NullArgumentForNonNullParameter] Null is not permitted for parameter 'value' of method 'containsEntry'.
[ERROR]     (see https://errorprone.info/bugpattern/NullArgumentForNonNullParameter)
[...]
[ERROR] /[...]/guava-33.7.1/guava-testlib/src/com/google/common/testing/EquivalenceTester.java:[112,81] [NullArgumentForNonNullParameter] Null is not permitted for parameter 'a' of method 'equivalent'.
[ERROR]     (see https://errorprone.info/bugpattern/NullArgumentForNonNullParameter)
[INFO] 37 errors 

Any ideas on how these errors could be mitigated? I've done some research and think it may require modifications to the source code, which I certainly don't feel qualified to do given my unfamiliarity with the codebase.

Note that I have applied the following two patches on top of the v33.7.1 repo to solve other build issues. The first aims to allow the build process to use an already installed JDK rather than downloading one (MacPorts has ports for various JDK versions which can be depended on). And the second prevents Error Prone from halting the build with an error.

--- pom.xml.orig	2026-08-18 13:13:06
+++ pom.xml	2026-09-01 16:50:12
@@ -390,17 +390,10 @@
           <executions>
             <execution>
               <goals>
-                <goal>toolchain</goal>
+                <goal>select-jdk-toolchain</goal>
               </goals>
             </execution>
           </executions>
-          <configuration>
-            <toolchains>
-              <jdk>
-                <version>26</version>
-              </jdk>
-            </toolchains>
-          </configuration>
         </plugin>
         <plugin>
           <groupId>org.codehaus.mojo</groupId>
--- pom.xml.orig	2026-08-18 13:13:06
+++ pom.xml	2026-09-01 18:00:07
@@ -223,6 +223,8 @@
 
               <!-- https://errorprone.info/docs/installation#maven -->
               <arg>-Xplugin:ErrorProne -Xep:Java8ApiChecker:ERROR -XepDisableAllWarnings</arg>
+              <!-- https://github.com/google/error-prone/issues/5426 -->
+              <arg>-XDaddTypeAnnotationsToSymbol=true</arg>
               <!-- https://github.com/google/error-prone/blob/f8e33bc460be82ab22256a7ef8b979d7a2cacaba/docs/installation.md#jdk-16 -->
               <!-- TODO(cpovirk): Use .mvn/jvm.config instead (per
                    https://errorprone.info/docs/installation#maven). -->

The build command itself is as follows.

% cd /[...]/guava-33.7.1
% mvn3 package -Dmaven.repo.local=/[...]/guava-33.7.1/.m2/repository -DskipTests --define maven.javadoc.skip --define toolchain.jdk.version="[11,)" --define toolchain.skip --projects !guava-tests

And here's some likely relevant version info.

% javac -version
javac 21.0.8
% java -version
java version "21.0.8" 2025-07-15 LTS
Java(TM) SE Runtime Environment (build 21.0.8+12-LTS-250)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.8+12-LTS-250, mixed mode, sharing)
% mvn3 --version
Apache Maven 3.9.16 (2bdd9fddda4b155ebf8000e807eb73fd829a51d5)
Maven home: /opt/local/share/java/maven3
Java version: 21.0.8, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home
Default locale: en_AU, platform encoding: UTF-8
OS name: "mac os x", version: "26.6.2", arch: "aarch64", family: "mac"
% uname -a
Darwin McDaAir.local 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:18:29 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T8122 arm64

Let me know if any further information is needed. And thanks for your time!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3no SLO

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions