Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazel built at HEAD can't build Bazel (java.lang.NoClassDefFoundError: javax/annotation/CheckReturnValue) #5532

Closed
jmillikin-stripe opened this issue Jul 6, 2018 · 8 comments
Assignees
Labels
P0 This is an emergency and more important than other current work. (Assignee required)

Comments

@jmillikin-stripe
Copy link
Contributor

Description of the problem / feature request:

A Bazel binary built at current HEAD (3ac44db) can't successfully bazel build //src:bazel, due to an unhandled exception from error-prone. I'm able to succesfully build Bazel using the 0.15.0 branch.

Since it's complaining about an unknown class, I wonder if buildjar is missing a dependency.

ERROR: /Users/jmillikin/src/bazel/src/objc_tools/bundlemerge/BUILD:16:1: Building src/objc_tools/bundlemerge/libbundlemerge_lib.jar (1 source file) failed (Exit 1)
src/objc_tools/bundlemerge/java/com/google/devtools/build/xcode/bundlemerge/BundleMerging.java:138: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
  static BundleMerging merging(Path tempDir, FileSystem fileSystem, Control control)
                       ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:
  
     error-prone version: 2.3.1
     BugPattern: CheckReturnValue
     Stack Trace:
     java.lang.NoClassDefFoundError: javax/annotation/CheckReturnValue
  	at com.google.errorprone.bugpatterns.CheckReturnValue.matchMethod(CheckReturnValue.java:142)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:889)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:145)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:587)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:145)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:144)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:602)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:145)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:64)
  	at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
  	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
  	at com.google.devtools.build.buildjar.javac.plugins.errorprone.ErrorPronePlugin.postFlow(ErrorPronePlugin.java:110)
  	at com.google.devtools.build.buildjar.javac.BlazeJavaCompiler.flow(BlazeJavaCompiler.java:112)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1363)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:959)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
  	at com.google.devtools.build.buildjar.javac.BlazeJavacMain.compile(BlazeJavacMain.java:110)
  	at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder$2.invokeJavac(SimpleJavaLibraryBuilder.java:122)
  	at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.compileSources(ReducedClasspathJavaLibraryBuilder.java:54)
  	at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.compileJavaLibrary(SimpleJavaLibraryBuilder.java:125)
  	at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:133)
  	at com.google.devtools.build.buildjar.BazelJavaBuilder.processRequest(BazelJavaBuilder.java:105)
  	at com.google.devtools.build.buildjar.BazelJavaBuilder.runPersistentWorker(BazelJavaBuilder.java:67)
  	at com.google.devtools.build.buildjar.BazelJavaBuilder.main(BazelJavaBuilder.java:45)
  Caused by: java.lang.ClassNotFoundException: javax.annotation.CheckReturnValue
  	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
  	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
  	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
  	... 43 more

What operating system are you running Bazel on?

MacOS

What's the output of bazel info release?

I'm using Bazel build from Git at 3ac44db (current HEAD)

@lfpino
Copy link
Contributor

lfpino commented Jul 6, 2018

@cushon can you please take a look?

@jmillikin-stripe
Copy link
Contributor Author

@buchgr I think this may be caused by 4c9a0c8 ("reduce the size of bazel's embedded jdk")

@cushon
Copy link
Contributor

cushon commented Jul 7, 2018

I can reproduce this on my mac, and I confirmed that it was introduced by 4c9a0c8.

@cushon
Copy link
Contributor

cushon commented Jul 7, 2018

Also, I can't repro on linux. Is the reduced mac JDK supposed to be different than the linux one?

@buchgr buchgr added the P0 This is an emergency and more important than other current work. (Assignee required) label Jul 9, 2018
@buchgr
Copy link
Contributor

buchgr commented Jul 9, 2018

I am taking a look. I built the JDK containing all modules listed ./full-jdk/bin/java --list-modules on all platforms. The class javax.annotation.CheckReturnValue does not appear to be part of the JDK. Also, everything seems to be working on CI. Is it possible that we don't test with embedded JDK?

@buchgr
Copy link
Contributor

buchgr commented Jul 9, 2018

The class seems to be part of the jsr305 third party dependency and it also exists in there.

@cushon
Copy link
Contributor

cushon commented Jul 9, 2018

Is it possible that we don't test with embedded JDK?

The tests build //src:bazel with a previous release (e.g. 0.15.0-homebrew), and then run the tests against the output of //src:bazel without overriding --host_javabase, so it's using the embedded JDK. Apparently there aren't any tests that build Bazel at head with itself, though.

@buchgr
Copy link
Contributor

buchgr commented Jul 9, 2018

@cushon we have a bazel determinism test that does just that and that for reasons has been disabled on macOS. I ll enable it again on our postsubmit pipeline once my fix is in.

c-parsons pushed a commit that referenced this issue Jul 9, 2018
I missed the java.instrument module when building the
smaller openjdk. I have updated the jdk to include this
module. This was the cause for #5532.

The image was created by https://buildkite.com/bazel/build-embedded-jdk/builds/23

RELNOTES: None
PiperOrigin-RevId: 203797576
natansil pushed a commit to natansil/bazel that referenced this issue Jul 24, 2018
I missed the java.instrument module when building the
smaller openjdk. I have updated the jdk to include this
module. This was the cause for bazelbuild#5532.

The image was created by https://buildkite.com/bazel/build-embedded-jdk/builds/23

RELNOTES: None
PiperOrigin-RevId: 203797576
bazel-io pushed a commit that referenced this issue Jul 31, 2018
Baseline: 4f64b77

Cherry picks:
   + 4c9a0c8:
     reduce the size of bazel's embedded jdk
   + d3228b6:
     remote: limit number of open tcp connections by default. Fixes
     #5491
   + 8ff87c1:
     Fix autodetection of linker flags
   + c4622ac:
     Fix autodetection of -z linker flags
   + 1021965:
     blaze_util_posix.cc: fix order of #define
   + ab1f269:
     blaze_util_freebsd.cc: include path.h explicitly
   + 68e92b4:
     openjdk: update macOS openjdk image. Fixes #5532
   + f45c224:
     Set the start time of binary and JSON profiles to zero correctly.
   + bca1912:
     remote: fix race on download error. Fixes #5047
   + 3842bd3:
     jdk: use parallel old gc and disable compact strings

Incompatible changes:

  - The $(ANDROID_CPU) Make variable is not available anymore. Use
    $(TARGET_CPU) after an Android configuration transition instead.
  - The $(JAVA_TRANSLATIONS) Make variable is not supported anymore.
  - Skylark structs (using struct()) may no longer have to_json and
    to_proto overridden.
  - The mobile-install --skylark_incremental_res flag is no longer
    available, use the --skylark flag instead.

New features:

  - android_local_test now takes advantage of Robolectric's binary
    resource processing which allows for faster tests.
  - Allow @ in package names.

Important changes:

  - Option --glibc is removed, toolchain selection relies solely on
    --cpu and --compiler options.
  - Build support for enabling cross binary FDO optimization.
  - The --distdir option is no longer experimental. This
      option allows to specify additional directories to look for
      files before trying to fetch them from the network. Files from
      any of the distdirs are only used if a checksum for the file
      is specified and both, the filename and the checksum, match.
  - Java coverage works now with multiple jobs.
  - Flip default value of --experimental_shortened_obj_file_path to
    true, Bazel now generates short object file path by default.
  - New rules for importing Android dependencies:
    `aar_import_external` and `aar_maven_import_external`.
    `aar_import_external` enables specifying external AAR
    dependencies using a list of HTTP URLs for the artifact.
    `aar_maven_import_external` enables specifying external AAR
    dependencies using the artifact coordinate and a list of server
    URLs.
  - The BAZEL_JAVAC_OPTS environment variable allows arguments, e.g.,
    "-J-Xmx2g", may be passed to the javac compiler during bootstrap
    build. This is helpful if your system chooses too small of a max
    heap size for the Java compiler during the bootstrap build.
  - --noexpand_configs_in_place is deprecated.
  - A tool to parse the Bazel execution log.
  - Support for LIPO has been fully removed.
  - Remove support for --discard_actions_after_execution.
  - Add --materialize_param_files flag to write parameter files even
    when actions are executed remotely.
  - Windows default system bazelrc is read from the user's
    ProgramData if present.
  - --[no]allow_undefined_configs no longer exists, passing undefined
    configs is an error.
  - In remote caching we limit the number of open
    TCP connections to 100 by default. The number can be adjusted
    by specifying the --remote_max_connections flag.
werkt pushed a commit to werkt/bazel that referenced this issue Aug 2, 2018
I missed the java.instrument module when building the
smaller openjdk. I have updated the jdk to include this
module. This was the cause for bazelbuild#5532.

The image was created by https://buildkite.com/bazel/build-embedded-jdk/builds/23

RELNOTES: None
PiperOrigin-RevId: 203797576
buchgr pushed a commit to buchgr/bazel that referenced this issue Aug 7, 2018
Baseline: 4f64b77

Cherry picks:
   + 4c9a0c8:
     reduce the size of bazel's embedded jdk
   + d3228b6:
     remote: limit number of open tcp connections by default. Fixes
     bazelbuild#5491
   + 8ff87c1:
     Fix autodetection of linker flags
   + c4622ac:
     Fix autodetection of -z linker flags
   + 1021965:
     blaze_util_posix.cc: fix order of #define
   + ab1f269:
     blaze_util_freebsd.cc: include path.h explicitly
   + 68e92b4:
     openjdk: update macOS openjdk image. Fixes bazelbuild#5532
   + f45c224:
     Set the start time of binary and JSON profiles to zero correctly.
   + bca1912:
     remote: fix race on download error. Fixes bazelbuild#5047
   + 3842bd3:
     jdk: use parallel old gc and disable compact strings

Incompatible changes:

  - The $(ANDROID_CPU) Make variable is not available anymore. Use
    $(TARGET_CPU) after an Android configuration transition instead.
  - The $(JAVA_TRANSLATIONS) Make variable is not supported anymore.
  - Skylark structs (using struct()) may no longer have to_json and
    to_proto overridden.
  - The mobile-install --skylark_incremental_res flag is no longer
    available, use the --skylark flag instead.

New features:

  - android_local_test now takes advantage of Robolectric's binary
    resource processing which allows for faster tests.
  - Allow @ in package names.

Important changes:

  - Option --glibc is removed, toolchain selection relies solely on
    --cpu and --compiler options.
  - Build support for enabling cross binary FDO optimization.
  - The --distdir option is no longer experimental. This
      option allows to specify additional directories to look for
      files before trying to fetch them from the network. Files from
      any of the distdirs are only used if a checksum for the file
      is specified and both, the filename and the checksum, match.
  - Java coverage works now with multiple jobs.
  - Flip default value of --experimental_shortened_obj_file_path to
    true, Bazel now generates short object file path by default.
  - New rules for importing Android dependencies:
    `aar_import_external` and `aar_maven_import_external`.
    `aar_import_external` enables specifying external AAR
    dependencies using a list of HTTP URLs for the artifact.
    `aar_maven_import_external` enables specifying external AAR
    dependencies using the artifact coordinate and a list of server
    URLs.
  - The BAZEL_JAVAC_OPTS environment variable allows arguments, e.g.,
    "-J-Xmx2g", may be passed to the javac compiler during bootstrap
    build. This is helpful if your system chooses too small of a max
    heap size for the Java compiler during the bootstrap build.
  - --noexpand_configs_in_place is deprecated.
  - A tool to parse the Bazel execution log.
  - Support for LIPO has been fully removed.
  - Remove support for --discard_actions_after_execution.
  - Add --materialize_param_files flag to write parameter files even
    when actions are executed remotely.
  - Windows default system bazelrc is read from the user's
    ProgramData if present.
  - --[no]allow_undefined_configs no longer exists, passing undefined
    configs is an error.
  - In remote caching we limit the number of open
    TCP connections to 100 by default. The number can be adjusted
    by specifying the --remote_max_connections flag.
buchgr added a commit to buchgr/bazel that referenced this issue Aug 7, 2018
c-parsons pushed a commit that referenced this issue Aug 8, 2018
I missed the java.instrument module when building the
smaller openjdk. I have updated the jdk to include this
module. This was the cause for #5532.

The image was created by https://buildkite.com/bazel/build-embedded-jdk/builds/23

RELNOTES: None
PiperOrigin-RevId: 203797576
buchgr added a commit to buchgr/bazel that referenced this issue Aug 9, 2018
I missed the java.instrument module when building the
smaller openjdk. I have updated the jdk to include this
module. This was the cause for bazelbuild#5532.

The image was created by https://buildkite.com/bazel/build-embedded-jdk/builds/23

RELNOTES: None
PiperOrigin-RevId: 203797576
bazel-io pushed a commit that referenced this issue Aug 13, 2018
Baseline: 4f64b77

Cherry picks:
   + 4c9a0c8:
     reduce the size of bazel's embedded jdk
   + d3228b6:
     remote: limit number of open tcp connections by default. Fixes
     #5491
   + 8ff87c1:
     Fix autodetection of linker flags
   + c4622ac:
     Fix autodetection of -z linker flags
   + 1021965:
     blaze_util_posix.cc: fix order of #define
   + ab1f269:
     blaze_util_freebsd.cc: include path.h explicitly
   + 68e92b4:
     openjdk: update macOS openjdk image. Fixes #5532
   + f45c224:
     Set the start time of binary and JSON profiles to zero correctly.
   + bca1912:
     remote: fix race on download error. Fixes #5047
   + 3842bd3:
     jdk: use parallel old gc and disable compact strings
   + 6bd0bdf:
     Add objc-fully-link to the list of actions that require the
     apple_env feature. This fixes apple_static_library functionality.
   + f330439:
     Add the action_names_test_files target to the OSS version of
     tools/buils_defs/cc/BUILD.
   + d215b64:
     Fix StackOverflowError on Windows. Fixes #5730
   + 366da4c:
     In java_rules_skylark depend on the javabase through
     //tools/jdk:current_java_runtime
   + 30c601d:
     Don't use @local_jdk for jni headers
   + c56699d:
     'DumpPlatformClasspath' now dumps the current JDK's default
     platform classpath

This release is a patch release that contains fixes for several serious
regressions that were found after the release of Bazel 0.16.0.

In particular this release resolves the following issues:

 - Bazel crashes with a StackOverflowError on Windows (See #5730)
 - Bazel requires a locally installed JDK and does not fall back
   to the embedded JDK (See #5744)
 - Bazel fails to build for Homebrew on macOS El Capitan (See #5777)
 - A regression in apple_static_library (See #5683)

Please watch our blog for a more detailed release announcement.
laurentlb pushed a commit that referenced this issue Sep 12, 2018
I missed the java.instrument module when building the
smaller openjdk. I have updated the jdk to include this
module. This was the cause for #5532.

The image was created by https://buildkite.com/bazel/build-embedded-jdk/builds/23

RELNOTES: None
PiperOrigin-RevId: 203797576
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 This is an emergency and more important than other current work. (Assignee required)
Projects
None yet
Development

No branches or pull requests

4 participants