Repository navigation
Closed
Labels
team-AndroidIssues for Android team
Description
Description of the problem / feature request:
When building an android_library, Bazel builds java_library deps as Java 1.9 since it went to the JDK9.
This results in the following proguard issues when building downstream, for instance with Protobuf Javalite:
Warning: com.google.protobuf.ByteBufferWriter: can't find referenced method 'java.nio.ByteBuffer position(int)' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.CodedOutputStream$ArrayEncoder: can't find referenced method 'java.nio.ByteBuffer clear()' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.CodedOutputStream$ByteOutputEncoder: can't find referenced method 'java.nio.ByteBuffer clear()' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.CodedOutputStream$NioEncoder: can't find referenced method 'java.nio.ByteBuffer clear()' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.CodedOutputStream$NioEncoder: can't find referenced method 'java.nio.ByteBuffer position(int)' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.CodedOutputStream$NioHeapEncoder: can't find referenced method 'java.nio.ByteBuffer position(int)' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.CodedOutputStream$OutputStreamEncoder: can't find referenced method 'java.nio.ByteBuffer clear()' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.Internal: can't find referenced method 'java.nio.ByteBuffer clear()' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.NioByteString: can't find referenced method 'java.nio.ByteBuffer position(int)' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.NioByteString: can't find referenced method 'java.nio.ByteBuffer limit(int)' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.NioByteString$1: can't find referenced method 'java.nio.ByteBuffer mark()' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.NioByteString$1: can't find referenced method 'java.nio.ByteBuffer reset()' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.Utf8$Processor: can't find referenced method 'java.nio.ByteBuffer position(int)' in library class java.nio.ByteBuffer
Warning: com.google.protobuf.Utf8$UnsafeProcessor: can't find referenced method 'java.nio.ByteBuffer position(int)' in library class java.nio.ByteBuffer
The issue is fixed by manually reverting to JDK8 with the following options:
build:jdk8 --javabase=@local_jdk//:jdk
build:jdk8 --host_javabase=@local_jdk//:jdk
build:jdk8 --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
build:jdk8 --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
Android does not support java.nio nor JDK9 yet.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Build an Android app with proguard and Protobuf Javalite.
What operating system are you running Bazel on?
OSX
What's the output of bazel info release?
release 0.16.1
Have you found anything relevant by searching the web?
I found an issue that said to manually add --javacopts="-source 8 -target 8". Not sure this is the recommended way until Bazel does it itself ?
Thanks!
Metadata
Metadata
Assignees
Labels
team-AndroidIssues for Android team
Activity
steeve commentedon Aug 24, 2018
Probably because this doesn't check for Java 1.9 https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/bazel/rules/android/BazelAndroidSemantics.java#L46
steeve commentedon Aug 24, 2018
This also results in the following Bazel warnings when building:
cushon commentedon Aug 24, 2018
Does this reproduce with 0.17 or Bazel at head? This might be the same issue as #5888.
jin commentedon Aug 24, 2018
I can reproduce this problem with building an Android app and RBE, with the following bazelrc config:
https://github.com/bazelbuild/bazel-toolchains/blob/a47750aac6225fdf3f28faea8f378b61eb965786/bazelrc/bazel-0.16.1.bazelrc#L42:L45
cushon commentedon Aug 24, 2018
@jin which Bazel version you reproduce with? Are you seeing with issue with the 0.17rc and at head, or just at 0.16.1?
jin commentedon Aug 24, 2018
Just 0.17.1rc1 and HEAD. 0.16.1 is fine.
cushon commentedon Aug 24, 2018
I think this is still #5888, and the issue is that when Bazel is built at HEAD or 0.17rc using 0.16.1, 0.16.1 produces a Bazel binary that contains the linkage issue.
If I build Bazel at head and then re-build using the HEAD binary (i.e.
bazel build //src::bazel && bazel-bin/src/bazel build //src:bazel) then I get a binary that doesn't exhibit this bug.jin commentedon Aug 24, 2018
@buchgr @philwo it looks like the release pipeline needs to be updated to build the release Bazel with itself. Can this be done?
Marking this as a release blocker.
3 remaining items
steeve commentedon Aug 27, 2018
Catching up with the issue, it's great you guys found the issue!
philwo commentedon Aug 27, 2018
I don't know - can we? :D From a config perspective, we just have to add it here:
https://github.com/bazelbuild/bazel/blob/master/.bazelci/presubmit.yml#L120
https://github.com/bazelbuild/bazel/blob/master/.bazelci/postsubmit.yml#L93
Can you try if it works and send me a CL with the changes?
jin commentedon Aug 27, 2018
Opened #6007
laurentlb commentedon Aug 28, 2018
Please let me know if there's a cherrypick to do in Bazel release.
jin commentedon Aug 28, 2018
jin commentedon Aug 30, 2018
I can verify that building the latest bazel with the latest rc (0.17.1rc1) fixes this issue. @steeve, please reopen if you are still running into this issue.
steeve commentedon Sep 15, 2018
Hey guys, sorry I report I'm still running into this issue with 0.17.1 (sorry I couldn't test earlier).
However this time the bazelrc workaround doesn't work:
cushon commentedon Sep 15, 2018
@steeve can you provide steps for reproducing the problem you're seeing?
steeve commentedon Sep 15, 2018
@cushon I put together a repro repo for both scenarios: https://github.com/steeve/bazel_issue_5978
cushon commentedon Sep 15, 2018
@steeve thanks! I started a new issue for this: #6159.
steeve commentedon Sep 15, 2018
Thanks!
Although I'm not sure we are supposed to force JDK8 for building Android apps are we ?
Without forcing JDK8 it "works", but:
Ultimately this won't work because Android doesn't support JDK >8.
I'm think we might want to keep this issue open, wether it's in the form of documentation (to tell people to force using jdk8) or fixing it altogether.
Quiet more warnings from com.google.protobuf.UnsafeUtil