Automated rollback of commit 27cecf175d9313acf41b4a71991def32d1beb3a6.

*** Reason for rollback ***

Broke the cider aspect

*** Original change description ***

Remove vestigial support for 'extclasspaths'

this isn't being used, we just add the jars in the 'extdir' to the
bootclasspath.

PiperOrigin-RevId: 293958757
diff --git a/src/java_tools/buildjar/BUILD b/src/java_tools/buildjar/BUILD
index 2fcf721..d1f14d6 100644
--- a/src/java_tools/buildjar/BUILD
+++ b/src/java_tools/buildjar/BUILD
@@ -62,6 +62,7 @@
     # single jar that contains the contents of both the bootclasspath and
     # extdirs.
     bootclasspath = ["//tools/jdk:platformclasspath.jar"],
+    extclasspath = [],
     genclass = ["bootstrap_genclass_deploy.jar"],
     ijar = ["//third_party/ijar"],
     javabuilder = ["bootstrap_VanillaJavaBuilder_deploy.jar"],
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/JavaLibraryBuildRequest.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/JavaLibraryBuildRequest.java
index c039836..2a40104 100644
--- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/JavaLibraryBuildRequest.java
+++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/JavaLibraryBuildRequest.java
@@ -54,6 +54,7 @@
   private final ImmutableList<Path> sourcePath;
   private final ImmutableList<Path> classPath;
   private final ImmutableList<Path> bootClassPath;
+  private final ImmutableList<Path> extClassPath;
 
   private final ImmutableList<Path> processorPath;
   private final List<String> processorNames;
@@ -122,7 +123,10 @@
     }
     depsBuilder.addDepsArtifacts(asPaths(optionsParser.getDepsArtifacts()));
     depsBuilder.setPlatformJars(
-        optionsParser.getBootClassPath().stream().map(Paths::get).collect(toImmutableSet()));
+        ImmutableSet.<Path>builder()
+            .addAll(asPaths(optionsParser.getBootClassPath()))
+            .addAll(asPaths(optionsParser.getExtClassPath()))
+            .build());
     if (optionsParser.reduceClasspathMode() != OptionsParser.ReduceClasspathMode.NONE) {
       depsBuilder.setReduceClasspath();
     }
@@ -155,6 +159,7 @@
     this.classPath = asPaths(optionsParser.getClassPath());
     this.sourcePath = asPaths(optionsParser.getSourcePath());
     this.bootClassPath = asPaths(optionsParser.getBootClassPath());
+    this.extClassPath = asPaths(optionsParser.getExtClassPath());
     this.processorPath = asPaths(optionsParser.getProcessorPath());
     this.processorNames = optionsParser.getProcessorNames();
     this.builtinProcessorNames = ImmutableSet.copyOf(optionsParser.getBuiltinProcessorNames());
@@ -232,6 +237,10 @@
     return bootClassPath;
   }
 
+  public ImmutableList<Path> getExtClassPath() {
+    return extClassPath;
+  }
+
   public ImmutableList<Path> getProcessorPath() {
     return processorPath;
   }
@@ -309,7 +318,11 @@
         BlazeJavacArguments.builder()
             .classPath(classPath)
             .classOutput(getClassDir())
-            .bootClassPath(getBootClassPath())
+            .bootClassPath(
+                ImmutableList.<Path>builder()
+                    .addAll(getBootClassPath())
+                    .addAll(getExtClassPath())
+                    .build())
             .javacOptions(makeJavacArguments())
             .sourceFiles(ImmutableList.copyOf(getSourceFiles()))
             .processors(null)
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/OptionsParser.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/OptionsParser.java
index 4aeb301..5099acb 100644
--- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/OptionsParser.java
+++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/OptionsParser.java
@@ -79,6 +79,7 @@
   private final List<String> classPath = new ArrayList<>();
   private final List<String> sourcePath = new ArrayList<>();
   private final List<String> bootClassPath = new ArrayList<>();
+  private final List<String> extClassPath = new ArrayList<>();
 
   private final List<String> processorPath = new ArrayList<>();
   private final List<String> processorNames = new ArrayList<>();
@@ -185,8 +186,7 @@
           break;
         case "--extclasspath":
         case "--extdir":
-          // TODO(b/149114743): remove this flag once Blaze stops passing it
-          collectFlagArguments(new ArrayList<>(), argQueue, "-");
+          collectFlagArguments(extClassPath, argQueue, "-");
           break;
         case "--output":
           outputJar = getArgument(argQueue, arg);
@@ -420,6 +420,9 @@
     return sourcePath;
   }
 
+  public List<String> getExtClassPath() {
+    return extClassPath;
+  }
 
   public List<String> getProcessorPath() {
     return processorPath;
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/VanillaJavaBuilder.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/VanillaJavaBuilder.java
index 38506c3..49b8ae8 100644
--- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/VanillaJavaBuilder.java
+++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/VanillaJavaBuilder.java
@@ -251,7 +251,9 @@
       OptionsParser optionsParser, StandardJavaFileManager fileManager, Path nativeHeaderDir)
       throws IOException {
     fileManager.setLocation(StandardLocation.CLASS_PATH, toFiles(optionsParser.getClassPath()));
-    Iterable<File> bootClassPath = toFiles(optionsParser.getBootClassPath());
+    Iterable<File> bootClassPath =
+        Iterables.concat(
+            toFiles(optionsParser.getBootClassPath()), toFiles(optionsParser.getExtClassPath()));
     // The bootclasspath may legitimately be empty if --release is being used.
     if (!Iterables.isEmpty(bootClassPath)) {
       fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, bootClassPath);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java
index c393ad5..69051d0 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java
@@ -284,6 +284,7 @@
     builder.setClasspathEntries(attributes.getCompileTimeClassPath());
     builder.setBootclasspathEntries(getBootclasspathOrDefault());
     builder.setSourcePathEntries(attributes.getSourcePath());
+    builder.setExtdirInputs(getExtdirInputs());
     builder.setToolsJars(javaToolchain.getTools());
     builder.setJavaBuilder(javaToolchain.getJavaBuilder());
     if (!turbineAnnotationProcessing) {
@@ -487,7 +488,11 @@
     builder.setSourceFiles(attributes.getSourceFiles());
     builder.setSourceJars(attributes.getSourceJars());
     builder.setClasspathEntries(attributes.getCompileTimeClassPath());
-    builder.setBootclasspathEntries(getBootclasspathOrDefault());
+    builder.setBootclasspathEntries(
+        NestedSetBuilder.<Artifact>stableOrder()
+            .addTransitive(getBootclasspathOrDefault())
+            .addTransitive(getExtdirInputs())
+            .build());
     // Exclude any per-package configured data (see JavaCommon.computePerPackageData).
     // It is used to allow Error Prone checks to load additional data,
     // and Error Prone doesn't run during header compilation.
@@ -830,6 +835,11 @@
     return javaToolchain.getBootclasspath();
   }
 
+  /** Returns the extdir artifacts. */
+  private final NestedSet<Artifact> getExtdirInputs() {
+    return javaToolchain.getExtclasspath();
+  }
+
   /**
    * Creates the Action that creates ijars from Jar files.
    *
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileActionBuilder.java
index 827b373..05e8578 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileActionBuilder.java
@@ -158,6 +158,7 @@
   private NestedSet<Artifact> bootclasspathEntries =
       NestedSetBuilder.emptySet(Order.NAIVE_LINK_ORDER);
   private ImmutableList<Artifact> sourcePathEntries = ImmutableList.of();
+  private NestedSet<Artifact> extdirInputs = NestedSetBuilder.emptySet(Order.NAIVE_LINK_ORDER);
   private FilesToRunProvider javaBuilder;
   private NestedSet<Artifact> toolsJars = NestedSetBuilder.emptySet(Order.NAIVE_LINK_ORDER);
   private PathFragment sourceGenDirectory;
@@ -240,7 +241,8 @@
         .addAll(sourceFiles)
         .addTransitive(javabaseInputs)
         .addTransitive(bootclasspathEntries)
-        .addAll(sourcePathEntries);
+        .addAll(sourcePathEntries)
+        .addTransitive(extdirInputs);
     if (coverageArtifact != null) {
       mandatoryInputs.add(coverageArtifact);
     }
@@ -330,6 +332,7 @@
       result.add("--compress_jar");
     }
     result.addExecPath("--output_deps_proto", outputs.depsProto());
+    result.addExecPaths("--extclasspath", extdirInputs);
     result.addExecPaths("--bootclasspath", bootclasspathEntries);
     result.addExecPaths("--sourcepath", sourcePathEntries);
     result.addExecPaths("--processorpath", plugins.processorClasspath());
@@ -466,6 +469,11 @@
     return this;
   }
 
+  public JavaCompileActionBuilder setExtdirInputs(NestedSet<Artifact> extdirEntries) {
+    this.extdirInputs = extdirEntries;
+    return this;
+  }
+
   /** Sets the directory where source files generated by annotation processors should be stored. */
   public JavaCompileActionBuilder setSourceGenDirectory(PathFragment sourceGenDirectory) {
     this.sourceGenDirectory = sourceGenDirectory;
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchain.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchain.java
index 9d46758..52c1ea8 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchain.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchain.java
@@ -59,6 +59,8 @@
     ImmutableList<String> javacopts = getJavacOpts(ruleContext);
     NestedSet<Artifact> bootclasspath =
         PrerequisiteArtifacts.nestedSet(ruleContext, "bootclasspath", Mode.HOST);
+    NestedSet<Artifact> extclasspath =
+        PrerequisiteArtifacts.nestedSet(ruleContext, "extclasspath", Mode.HOST);
     boolean javacSupportsWorkers =
         ruleContext.attributes().get("javac_supports_workers", Type.BOOLEAN);
     Artifact javac = ruleContext.getPrerequisiteArtifact("javac", Mode.HOST);
@@ -140,6 +142,7 @@
             turbineJvmOpts,
             javacSupportsWorkers,
             bootclasspath,
+            extclasspath,
             javac,
             tools,
             javabuilder,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainProvider.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainProvider.java
index 66e577e..b8c5df0 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainProvider.java
@@ -78,6 +78,7 @@
       ImmutableList<String> turbineJvmOptions,
       boolean javacSupportsWorkers,
       NestedSet<Artifact> bootclasspath,
+      NestedSet<Artifact> extclasspath,
       @Nullable Artifact javac,
       NestedSet<Artifact> tools,
       FilesToRunProvider javaBuilder,
@@ -102,6 +103,7 @@
     return new JavaToolchainProvider(
         label,
         bootclasspath,
+        extclasspath,
         javac,
         tools,
         javaBuilder,
@@ -132,6 +134,7 @@
 
   private final Label label;
   private final NestedSet<Artifact> bootclasspath;
+  private final NestedSet<Artifact> extclasspath;
   @Nullable private final Artifact javac;
   private final NestedSet<Artifact> tools;
   private final FilesToRunProvider javaBuilder;
@@ -163,6 +166,7 @@
   JavaToolchainProvider(
       Label label,
       NestedSet<Artifact> bootclasspath,
+      NestedSet<Artifact> extclasspath,
       @Nullable Artifact javac,
       NestedSet<Artifact> tools,
       FilesToRunProvider javaBuilder,
@@ -193,6 +197,7 @@
 
     this.label = label;
     this.bootclasspath = bootclasspath;
+    this.extclasspath = extclasspath;
     this.javac = javac;
     this.tools = tools;
     this.javaBuilder = javaBuilder;
@@ -231,6 +236,11 @@
     return bootclasspath;
   }
 
+  /** @return the target Java extclasspath */
+  public NestedSet<Artifact> getExtclasspath() {
+    return extclasspath;
+  }
+
   /** Returns the {@link Artifact} of the javac jar */
   @Nullable
   public Artifact getJavac() {
diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/JavaCompileActionTestHelper.java b/src/test/java/com/google/devtools/build/lib/rules/java/JavaCompileActionTestHelper.java
index aa7fa61..05e7de8 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/java/JavaCompileActionTestHelper.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/java/JavaCompileActionTestHelper.java
@@ -86,6 +86,9 @@
     return getOptions(javac).getBootClassPath();
   }
 
+  public static List<String> getExtdir(JavaCompileAction javac) throws Exception {
+    return getOptions(javac).getExtClassPath();
+  }
 
   /** Returns the JavaBuilder command line, up to the main class or deploy jar. */
   public static List<String> getJavacCommand(JavaCompileAction action) throws Exception {