You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our internal build uses JDK 11 to build code against JDK 8, using the JDK 8 bootclasspath. When upgrading to Bazel 6, the Java runfiles library fails to compile:
external/bazel_tools/tools/java/runfiles/AutoBazelRepositoryProcessor.java:84: error: method iterate in interface Stream<T#2> cannot be applied to given types;
Stream.iterate(
^
required: T#1,UnaryOperator<T#1>
found: TypeElement,(element)-[...]ement,Element::g[...]ement
reason: cannot infer type-variable(s) T#1
(actual and formal argument lists differ in length)
where T#1,T#2 are type-variables:
T#1 extends Object declared in method <T#1>iterate(T#1,UnaryOperator<T#1>)
T#2 extends Object declared in interface Stream
Target @bazel_tools//tools/java/runfiles:auto_bazel_repository_processor failed to build
This appears to be occurring because the three-argument Stream.iterate method used here:
does not exist in JDK 8, there is only a two-argument one. It was added in JDK 9 (JDK 11 docs here.
A simple enough fix would be to replace this Stream call with a for loop, which seems to work for me locally. I can prepare a PR should this be desirable. My understanding is that while Bazel itself needs JDK 11, Bazel should still be able to compile code for JDK 8, including libraries intended to be loaded by end-users like this one.
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Since this only uses the standard library, you can just use javac from JDK 8 without invoking Bazel:
The three-argument overload of `Stream#iterate` is only available as of Java 9.
Fixes#17458Closes#17460.
PiperOrigin-RevId: 509885763
Change-Id: If83d832b3590b8598c0f4163afa3c7054e7c9786
Co-authored-by: Fabian Meumertzheim <[email protected]>
I'm seeing this issue with bazel 6.1.2. (It worked in 5.3.2.) Looking at 420659a, it looks like it made it into various 7.0.0-pre.* builds, but not into any 6.* build. Is it possible to cherry-pick it?
Description of the bug:
Our internal build uses JDK 11 to build code against JDK 8, using the JDK 8 bootclasspath. When upgrading to Bazel 6, the Java runfiles library fails to compile:
This appears to be occurring because the three-argument
Stream.iterate
method used here:bazel/tools/java/runfiles/AutoBazelRepositoryProcessor.java
Lines 84 to 90 in 338bbc0
does not exist in JDK 8, there is only a two-argument one. It was added in JDK 9 (JDK 11 docs here.
A simple enough fix would be to replace this
Stream
call with afor
loop, which seems to work for me locally. I can prepare a PR should this be desirable. My understanding is that while Bazel itself needs JDK 11, Bazel should still be able to compile code for JDK 8, including libraries intended to be loaded by end-users like this one.What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Since this only uses the standard library, you can just use
javac
from JDK 8 without invoking Bazel:javac tools/java/runfiles/AutoBazelRepositoryProcessor.java
Reproduced using OpenJDK 11 using the OpenJDK 8 bootclasspath, and OpenJDK 8 itself.
Which operating system are you running Bazel on?
Linux (Alma 8 aarch64, CentOS 7 amd64)
What is the output of
bazel info release
?6.0.0-vmware
If
bazel info release
returnsdevelopment 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
Have you found anything relevant by searching the web?
#17281 is in the same area, but does not correspond to this precise issue.
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: