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

strict java deps fails with local_java_repository #17877

Closed
nickbreen opened this issue Mar 24, 2023 · 5 comments
Closed

strict java deps fails with local_java_repository #17877

nickbreen opened this issue Mar 24, 2023 · 5 comments
Labels

Comments

@nickbreen
Copy link

nickbreen commented Mar 24, 2023

Description of the bug:

When using a local_java_repository strict java dependency checking flags all dependencies as transient and fails.

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

https://github.com/nickbreen/bz-java-import

bazel build //...

Output:

INFO: ToolchainResolution: Target platform @local_config_platform//:host: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain @local_config_cc//:cc-compiler-k8, type @bazel_tools//tools/jdk:toolchain_type -> toolchain @optjdk//:optjdk_toolchain_java11, type @bazel_tools//tools/jdk:runtime_toolchain_type -> toolchain @optjdk//:optjdk
INFO: Analyzed 3 targets (1 packages loaded, 9 targets configured).
INFO: Found 3 targets...
ERROR: /home/breenn/src/nickbreen/bz-java-import/some-annotation/BUILD.bazel:1:13: Building some-annotation/libsome-annotation.jar (1 source file) failed: (Exit 1): java failed: error executing command (from target //some-annotation:some-annotation) /mnt/scratch/lmax.cache/jdk11/11.0.10_9-2/bin/java -XX:-CompactStrings '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' ... (remaining 16 arguments skipped)
some-annotation/src/main/java/com/example/annotation/SomeAnnotation.java:15: error: [strict] Using type org.checkerframework.framework.qual.SubtypeOf from an indirect dependency (TOOL_INFO: "//checker-qual"). See command below **
@SubtypeOf({UnknownUnits.class})
 ^
 ** Please add the following dependencies: 
  //checker-qual to //some-annotation 
 ** You can use the following buildozer command: 
buildozer 'add deps //checker-qual' //some-annotation 

INFO: Elapsed time: 1.557s, Critical Path: 0.15s
INFO: 3 processes: 3 internal.
FAILED: Build did NOT complete successfully

Which operating system are you running Bazel on?

Fedora 37

What is the output of bazel info release?

release 6.0.0

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

N/A

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

N/A

Have you found anything relevant by searching the web?

Nothing that appears relevant.

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

--experimental_strict_java_deps=warn still finds and warns about the bogus failures.

I had initially thought it was a problem with java_import but when building up the test-case it also presented with a normal java_library.

@cushon
Copy link
Contributor

cushon commented Mar 29, 2023

/mnt/scratch/lmax.cache/jdk11/11.0.10_9-2

Can you try using a newer JDK 11 version? Strict Java deps depends on some javac changes that are only available in relatively recent JDK 11 update releases

@nickbreen
Copy link
Author

nickbreen commented Mar 29, 2023 via email

@cushon
Copy link
Contributor

cushon commented Mar 29, 2023

JDK 11.0.15 or newer, the history is in #14533

@nickbreen
Copy link
Author

Interestingly, updating just the JDK to 11.0.17+8 now produces an ErrorProne class not found error even though we're configured with the vanilla java builder.

error: SourceChecker.typeProcess: unexpected Throwable (CompletionFailure) while processing [ELIDED].java; message: class file for com.google.errorprone.annotations.DoNotMock not found
  ; The Checker Framework crashed.  Please report the crash.
  Compilation unit: [ELIDED].java
  Last visited tree at line 28 column 1:
  public enum [ELIDED]
  Exception: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for com.google.errorprone.annotations.DoNotMock not found; com.sun.tools.javac.code.Symbol$CompletionFailure: class file for com.google.errorprone.annotations.DoNotMock not found

The [ELIDED] enum is very simple and does not include any reference to errorprone.

My hunch is that this is due to our quirky definition of the JDK with:

new_local_repository(
    name = "optjdk",
    build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
    path = "opt/jdk11",
)

@nickbreen
Copy link
Author

Going back to local_java_repository is now working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants