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
{{ message }}
Repository navigation
"warning: could not find a JDK 8 bootclasspath in external/embedded_jdk, falling back to --release" on Bazel 0.19.0rc6 and master #6433
It's supposed to warn about builds that are using a JDK 9 --javabase but targeting the Java 8 language level. In that situation we use the infrastructure added to support the javac --release flag to get a bootclasspath for cross-compilation, but that approach doesn't provide access to internal (e.g. sun.misc.*) APIs, see: #6179.
Example:
./bazel-0.19.0rc6-linux-x86_64 build --define=ABSOLUTE_JAVABASE=$JAVA9_HOME \
--javabase @bazel_tools//tools/jdk:absolute_javabase ...
...
warning: could not find a JDK 8 bootclasspath in $JAVA9_HOME, falling back to --release
I'm surprised you're seeing that warning with a JDK 8 --javabase. That shouldn't happen. Do you have a repo? Does $JAVA_HOME/jre/lib/rt.jar exist on your system?
I can consistently reproduce it on gerrit reviewers plugin:
When I try to build that it tries to find gerrit-plugin-api-2.16-SNAPSHOT.jar in my local maven repository and then fails. Are there docs for how to get set up to reproduce?
However, recently, Gerrit snapshot was bumped to 3.0-SNAPSHOT, so that you would need to update reviewers plugin, to build against that snapshot version, by bumping bazlets version in WORKSPACE in reviewers plugin:
A simpler option to reproduce would be to use this change: [1], that updated the API to 2.16-rc0, that was released today morning to Maven Central: [2]. With this change: [1] cherry-picked on top of master of reviewers plugin, you could just build, without publishing snapshot version.
Thanks, I was able to repo with those instructions.
This is an issue with host-targeting-host compilations, since the default host JDK is 9 but we're still using the Java 8 language level in the host, and we can't find a JDK 8 bootclasspath in the host JDK.
genrule(
name = "g",
outs = ["o"],
cmd = "$(location b) > $@",
tools = ["b"],
)
public class B {
public static void main(String[] args) {
System.err.println("hello");
}
}
./bazel-0.19.0rc6-linux-x86_64 build :g
INFO: Analysed target //:g (15 packages loaded, 230 targets configured).
INFO: Found 1 target...
INFO: From SkylarkAction external/bazel_tools/tools/jdk/platformclasspath.jar [for host]:
warning: could not find a JDK 8 bootclasspath in external/embedded_jdk, falling back to --release
Here's a work-around that makes the current behaviour explicit and fixes the warning spam:
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
index b56e784c00..e8dfe53968 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java@@ -97,7 +97,7 @@ public class JavaOptions extends FragmentOptions {
@Option(
name = "host_java_toolchain",
- defaultValue = "@bazel_tools//tools/jdk:toolchain",+ defaultValue = "@bazel_tools//tools/jdk:toolchain_host",
converter = LabelConverter.class,
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
diff --git a/tools/jdk/BUILD b/tools/jdk/BUILD
index 53b72d65c1..80f33d4dc4 100644
--- a/tools/jdk/BUILD+++ b/tools/jdk/BUILD@@ -202,6 +202,18 @@ bootclasspath(
target_javabase = "current_java_runtime",
)
+# For use with host-targeting-host builds.+#+# The default host JDK is > 8 but we're using the Java 8 language level on the+# host, so we have no choice but to use --release for host-targeting-host+# builds.+bootclasspath(+ name = "platformclasspath8",+ src = "DumpPlatformClassPath.java",+ host_javabase = "current_java_runtime",+ release = "8",+)+
default_java_toolchain(
name = "toolchain_hostjdk8",
bootclasspath = [":platformclasspath"],
@@ -220,6 +232,15 @@ default_java_toolchain(
target_version = "8",
)
+# The default --host_java_toolchain+default_java_toolchain(+ name = "toolchain_host",+ bootclasspath = [":platformclasspath8"],+ jvm_opts = JDK9_JVM_OPTS,+ source_version = "8",+ target_version = "8",+)+
# The 'vanilla' toolchain is an unsupported alternative to the default.
#
# It does not provider any of the following features:
I don't have an opinion about whether this should be a release blocker. It isn't a functional regression, it's 'just' log spam.
@cushon Thanks for the quick fix. I confirmed, when applying that patch on Bazel master and building
reviewers plugin, the warning is gone.
Can you apply this patch on Bazel master? If Bazel teams decided not to fix this log spam regression in upcoming 0.19 release, we could skip that release and wait for the next release where this problem is fixed.
The issue is that using the host JDK 9's --release support instead of its default bootclasspath regresses #6179; --release 8 on JDK 9 doesn't include e.g. sun.misc.Unsafe.
I think the current behaviour is actually what we want. host-targeting-host compilations with a JDK 9 host_javabase are actually targeting JDK 9, so it's OK to use a JDK 9 bootclasspath. It's also OK to limit ourselves to the Java 8 language level.
Maybe we should just disable that warning, either for this specific use of DumpPlatformClasspath or in general.
Activity
cushon commentedon Oct 18, 2018
What combinations of Java toolchains and JDKs is that build using?
davido commentedon Oct 18, 2018
Only JDK 8, without any
java_toolchainparameters.cushon commentedon Oct 18, 2018
The message was introduced by 999354b.
It's supposed to warn about builds that are using a JDK 9
--javabasebut targeting the Java 8 language level. In that situation we use the infrastructure added to support the javac--releaseflag to get a bootclasspath for cross-compilation, but that approach doesn't provide access to internal (e.g.sun.misc.*) APIs, see: #6179.Example:
I'm surprised you're seeing that warning with a JDK 8
--javabase. That shouldn't happen. Do you have a repo? Does$JAVA_HOME/jre/lib/rt.jarexist on your system?hlopko commentedon Oct 18, 2018
cc @iirina
katre commentedon Oct 18, 2018
Potential release bloker for #6116.
davido commentedon Oct 18, 2018
Yes, it does exist:
I can consistently reproduce it on gerrit reviewers plugin:
davido commentedon Oct 18, 2018
And I also see this on gerrit itself:
cushon commentedon Oct 18, 2018
When I try to build that it tries to find
gerrit-plugin-api-2.16-SNAPSHOT.jarin my local maven repository and then fails. Are there docs for how to get set up to reproduce?davido commentedon Oct 18, 2018
Ah, right, you would need to publish gerrit plugin API, first.
Clone gerrit and run:
However, recently, Gerrit snapshot was bumped to 3.0-SNAPSHOT, so that you would need to update reviewers plugin, to build against that snapshot version, by bumping bazlets version in WORKSPACE in reviewers plugin:
That Bazlet change was merged earlier today: https://gerrit-review.googlesource.com/c/bazlets/+/200630.
Reviewers plugin wasn't updated yet on master to reflect that change.
Now you should be able to say:
davido commentedon Oct 18, 2018
A simpler option to reproduce would be to use this change: [1], that updated the API to 2.16-rc0, that was released today morning to Maven Central: [2]. With this change: [1] cherry-picked on top of master of reviewers plugin, you could just build, without publishing snapshot version.
cushon commentedon Oct 18, 2018
Thanks, I was able to repo with those instructions.
This is an issue with host-targeting-host compilations, since the default host JDK is 9 but we're still using the Java 8 language level in the host, and we can't find a JDK 8 bootclasspath in the host JDK.
cushon commentedon Oct 18, 2018
Here's a work-around that makes the current behaviour explicit and fixes the warning spam:
I don't have an opinion about whether this should be a release blocker. It isn't a functional regression, it's 'just' log spam.
@iirina and @lberki, WDYT?
davido commentedon Oct 19, 2018
@cushon Thanks for the quick fix. I confirmed, when applying that patch on Bazel master and building
reviewers plugin, the warning is gone.
Can you apply this patch on Bazel master? If Bazel teams decided not to fix this log spam regression in upcoming 0.19 release, we could skip that release and wait for the next release where this problem is fixed.
katre commentedon Oct 19, 2018
If the fix is this simple, I'd prefer to eliminate the confusing logs and cherrypick this into 0.19.0.
@iirina, @lberki can you comment?
10 remaining items
katre commentedon Oct 23, 2018
@cushon You should be able to sync to head and retry today.
cushon commentedon Oct 23, 2018
and now the CI is broken :/ https://buildkite.com/bazel/bazel-bazel/builds/5122
katre commentedon Oct 23, 2018
Sending a quick change to disable the failing test, will let you know when it's in
katre commentedon Oct 23, 2018
It's in.
Fix log spam with the host java_toolchain
Fix log spam with the host java_toolchain
Automated rollback of commit 5080238.
cushon commentedon Oct 24, 2018
The fix didn't stick:
https://storage.googleapis.com/bazel-buildkite-artifacts/ad153be8-d848-4ccc-b0df-4f0c631b1ab3/src/test/shell/bazel/bazel_determinism_test/attempt_1.log
The issue is that using the host JDK 9's
--releasesupport instead of its default bootclasspath regresses #6179;--release 8on JDK 9 doesn't include e.g.sun.misc.Unsafe.I think the current behaviour is actually what we want. host-targeting-host compilations with a JDK 9 host_javabase are actually targeting JDK 9, so it's OK to use a JDK 9 bootclasspath. It's also OK to limit ourselves to the Java 8 language level.
Maybe we should just disable that warning, either for this specific use of DumpPlatformClasspath or in general.
ittaiz commentedon Oct 24, 2018
cushon commentedon Oct 24, 2018
Yes:
sun.misc.Unsafeshould be available in all supported configurations, thanks to the fix for #6179.The warning tracked by this bug is unfortunate, but the functionality hasn't regressed.
Remove --release handling from DumpPlatformClassPath
cushon commentedon Oct 24, 2018
I submitted a different fix: 917d0cd.