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

Java 9: Missing strict dependency is erroneously reported #4812

Closed
davido opened this issue Mar 9, 2018 · 4 comments
Closed

Java 9: Missing strict dependency is erroneously reported #4812

davido opened this issue Mar 9, 2018 · 4 comments
Assignees

Comments

@davido
Copy link
Contributor

davido commented Mar 9, 2018

Description of the problem / feature request:

Bazel built with Java 9 from HEAD, with this PR applied, is reporting missing strict dependency. The reported missing dependency is in place.

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

  • Apply this PR on HEAD
  • Build Bazel with Java 9 with this command:
$ bazel --host_javabase=/usr/lib64/jvm/java-9-openjdk build \
  --javacopt='--release 9' \
  --java_toolchain=@bazel_tools//tools/jdk:toolchain_jdk9 \
  src:bazel
  • Clone bazel_printy test repository
  • Try to build printy_lib rule with Bazel built with java 9

Expected: build is successful

Actual: build is failing:

$ bazel build :printy_lib
INFO: Analysed target //:printy_lib (0 packages loaded).
INFO: Found 1 target and 0 test targets...
ERROR: /home/davido/projects/bazel_printy/BUILD:9:1: Building libprinty_lib.jar (1 source file) failed (Exit 1)
src/main/java/org/gerritcon/mv2016/Printy.java:22: error: [strict] Using type com.google.common.base.Joiner from an indirect dependency (TOOL_INFO: "@guava//jar"). See command below **
    System.out.println(Joiner.on(' ').join(argv));
                       ^
 ** Please add the following dependencies: 
  @guava//jar  to //:printy_lib 
 ** You can use the following buildozer command: 
buildozer 'add deps @guava//jar ' //:printy_lib 

Target //:printy_lib failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.481s, Critical Path: 0.32s
FAILED: Build did NOT complete successfully

Note, that printy_lib already depends on guava:

https://github.com/davido/bazel_printy/blob/master/BUILD#L9-L14

What operating system are you running Bazel on?

Linux, Java 9.

Related:

#4709

Known workarounds:

All is fine if I build Bazel with Java 8.

@cushon
Copy link
Contributor

cushon commented Mar 9, 2018

This is effectively a duplicate of #3410.

In particular, see:

@cushon cushon closed this as completed Mar 9, 2018
@davido
Copy link
Contributor Author

davido commented Mar 9, 2018

@cushon Thanks for the pointers. What is your recommendation to fix strict dependency problem when #4795 (or equivalent) is merged and we sorted out Java 9 gRpc issue? Do we really need to patch javac in Java 9 for strict dependencies to work properly?

@davido
Copy link
Contributor Author

davido commented Mar 10, 2018

I'm asking, because for now, strict dependency is the last unresolved issue for building Bazel and Gerrit Code Review eco-system with Java 9 (Bazel, Gerrit, JGit and Gitiles). With the disabled strict java deps feature I was able to build Bazel and use built Bazel with Java 9 and successfully build gerrit, see this CL pending for review: [1] and friends.

There are two known workarounds for this problem:

  • Pass --strict_java_deps=OFF to diable strict java deps feature
  • Dynamically detect the Java runtime and disable that feature, because we do know, it doesn't work: [2]

cushon added a commit to cushon/bazel that referenced this issue Mar 27, 2018
See bazelbuild#3410, bazelbuild#4812

Change-Id: Idd4adad7d48899c3b6de635d417446b71ba44afa
cushon added a commit to cushon/bazel that referenced this issue Mar 27, 2018
See bazelbuild#3410, bazelbuild#4812

Change-Id: Idd4adad7d48899c3b6de635d417446b71ba44afa
cushon added a commit to cushon/bazel that referenced this issue Mar 27, 2018
See bazelbuild#3410, bazelbuild#4812

Change-Id: Idd4adad7d48899c3b6de635d417446b71ba44afa
bazel-io pushed a commit that referenced this issue Mar 28, 2018
See #3410, #4812

Change-Id: Idd4adad7d48899c3b6de635d417446b71ba44afa
@davido
Copy link
Contributor Author

davido commented Apr 5, 2018

Thanks for the fix. It works now. I see, that the custom javac is used now

"--patch-module=java.compiler=$(location //third_party/java/jdk/langtools:java_compiler_jar)",
"--patch-module=jdk.compiler=$(location //third_party/java/jdk/langtools:jdk_compiler_jar)"

Where are those files are coming from?

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

No branches or pull requests

3 participants