Automated rollback of commit
*** Reason for rollback ***
Breaks guitar tests
*** Original change description ***
Allow --javabase to accept java_runtime (not just java_runtime_suite)
Fixes bazelbuild/bazel#3407
@@ -83,17 +83,13 @@ public final class JvmConfigurationLoader implements ConfigurationFragmentFactor
}
Target javaHomeTarget = lookup.getTarget(javaBase);
if (javaHomeTarget instanceof Rule) {
- switch (((Rule) javaHomeTarget).getRuleClass()) {
- case "java_runtime_suite":
- return createFromRuntimeSuite(lookup, (Rule) javaHomeTarget, cpu);
- case "java_runtime":
- return createFromRuntime(lookup, javaHomeTarget.getLabel());
- default:
+ if (!((Rule) javaHomeTarget).getRuleClass().equals("java_runtime_suite")) {
throw new InvalidConfigurationException(
"Unexpected javabase rule kind '"
+ ((Rule) javaHomeTarget).getRuleClass()
+ "'. Expected java_runtime_suite");
}
+ return createFromRuntimeSuite(lookup, (Rule) javaHomeTarget, cpu);
}
throw new InvalidConfigurationException(
"No JVM target found under " + javaBase + " that would work for " + cpu);
@@ -105,25 +101,11 @@ public final class JvmConfigurationLoader implements ConfigurationFragmentFactor
// TODO(b/34175492): eventually the Jvm fragement will containg only the label of a java_runtime
// rule, and all of the configuration will be accessed using JavaRuntimeInfo.
-
- private static Jvm createFromRuntimeSuite(
- ConfigurationEnvironment lookup, Rule javaRuntimeSuite, String cpu)
+ private static Jvm createFromRuntimeSuite(ConfigurationEnvironment lookup, Rule javaRuntimeSuite,
+ String cpu)
throws InvalidConfigurationException, InterruptedException, NoSuchTargetException,
NoSuchPackageException {
Label javaRuntimeLabel = selectRuntime(javaRuntimeSuite, cpu);
- PathFragment javaHome = getJavaHome(lookup, javaRuntimeLabel);
- return new Jvm(javaHome, javaRuntimeSuite.getLabel());
- }
-
- private static Jvm createFromRuntime(ConfigurationEnvironment lookup, Label javaRuntimeLabel)
- throws InvalidConfigurationException, InterruptedException, NoSuchTargetException,
- NoSuchPackageException {
- return new Jvm(getJavaHome(lookup, javaRuntimeLabel), javaRuntimeLabel);
- }
-
- private static PathFragment getJavaHome(ConfigurationEnvironment lookup, Label javaRuntimeLabel)
- throws NoSuchPackageException, NoSuchTargetException, InterruptedException,
- InvalidConfigurationException {
Target javaRuntimeTarget = lookup.getTarget(javaRuntimeLabel);
if (javaRuntimeTarget == null) {
return null;
@@ -150,7 +132,7 @@ public final class JvmConfigurationLoader implements ConfigurationFragmentFactor
javaHomePath, srcs.toString()));
}
}
- return javaHomePath;
+ return new Jvm(javaHomePath, javaRuntimeSuite.getLabel());
}
private static Label selectRuntime(Rule javaRuntimeSuite, String cpu)
