bazel: [6.3.0] nullaway plugin stops compiling

Description of the bug:

Nullaway error-prone plugin doesn’t work with 6.3.0 but did work with 6.1.2

What goes wrong is either

  1. –when set javaopts= setting is present in bazel-out/…/…jar-0.params.out but nullaway plugin can’t see it–
  2. or error-prone version bundled in 6.3.0 is somehow 2.19.1 with a bug https://github.com/google/error-prone/issues/3931 rather than 2.20.0

2.19.1 comes from remote_java_tools-v12.5

     Please report this at https://github.com/google/error-prone/issues/new and include the following:
  
     error-prone version: 2.19.1
     BugPattern: NullAway
     Stack Trace:
     java.lang.IllegalStateException: To run the NullAway analysis plugin please specify analysis options with -XepOpt:NullAway:[...]. You should at least specify annotated packages, using the -XepOpt:NullAway:AnnotatedPackages=[...] flag.

and the error message it not wrong

java_library(
  plugins = ["@maven//:com_uber_nullaway_nullaway"],
  javacopts = ["-Xep:NullAway:ERROR", "-XepOpt:NullAway:AnnotatedPackages=something",
  ...
)

bazel build --verbose_failures ... ; cat bazel-out/....jar-0.params shows -XepOpt:NullAway:AnnotatedPackages present

Difference in .params from 6.1.2 to 6.3.0 seems to be just

> -Xep:IgnoredPureGetter:OFF
> -Xep:EmptyTopLevelDeclaration:OFF
> -Xep:LenientFormatStringValidation:OFF
> -Xep:ReturnMissingNullable:OFF
> -Xep:UseCorrectAssertInTests:OFF

What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

WORKSPACE:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULES_JVM_EXTERNAL_TAG = "5.3"
RULES_JVM_EXTERNAL_SHA ="d31e369b854322ca5098ea12c69d7175ded971435e55c18dd9dd5f29cc5249ac"

http_archive(
    name = "rules_jvm_external",
    strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
    sha256 = RULES_JVM_EXTERNAL_SHA,
    url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG)
)

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
    name = "nullaway",
    artifacts = [
        "com.uber.nullaway:nullaway:0.10.11",
    ],
    repositories = [
        "https://repo1.maven.org/maven2",
    ],
)

BUILD

java_plugin(
    name = "nullaway",
    visibility = ["//visibility:public"],
    deps = [
        "@nullaway//:com_uber_nullaway_nullaway",
    ],
)

java_library(
  name = "a",
  javacopts = ["-Xep:NullAway:ERROR", "-XepOpt:NullAway:AnnotatedPackages=something"],
  plugins = [":nullaway"],
  srcs = ["A.java"],
)

A.java

class A {
}

Command

$ bazel build a --verbose_failures -s
...
...
A.java:1: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
class A {
^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:
  
     error-prone version: 2.19.1
     BugPattern: NullAway
     Stack Trace:
     java.lang.IllegalStateException: To run the NullAway analysis plugin please specify analysis options with -XepOpt:NullAway:[...]. You should at least specify annotated packages, using the -XepOpt:NullAway:AnnotatedPackages=[...] flag.
...

Which operating system are you running Bazel on?

NixOS

What is the output of bazel info release?

release 6.3.0- (@non-git)

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What’s the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

Didn’t find any obviously related change between 6.1.2 and 6.3.0 yet

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

Would be good to fix in 6.3.1 https://github.com/bazelbuild/bazel/issues/19045

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (14 by maintainers)

Commits related to this issue

Most upvoted comments

@meteorcloudy run it on some of the targets and looks like it got resolved 🎉

@bazel-io fork 6.4.0

I think it’s the opposite, java_tools 12.5 was built from sources of Bazel@HEAD, which still has errorprone 2.19.1: https://github.com/bazelbuild/bazel/blob/6eb7dbb2f2634a0acaee5dc8c73f0aab710e1256/WORKSPACE#L422-L426

@bazel-io fork 6.3.1