Add support for an unstripped bootclasspath

Running the bootclasspath through ijar was added in https://github.com/bazelbuild/rules_java/pull/324 and was always enabled. This change lets us selectively disable it. This ensures we don't end up depending on the prebuilt ijar in the non-prebuilt toolchain case. This is also needed to bootstrap bazel where we don't have access to `@remote_java_tools`

PiperOrigin-RevId: 828056087
Change-Id: I38402112139221cea606b64110fb1854795a8113
diff --git a/toolchains/BUILD b/toolchains/BUILD
index bb6ecf7..41a4f53 100644
--- a/toolchains/BUILD
+++ b/toolchains/BUILD
@@ -351,6 +351,17 @@
     }),
 )
 
+bootclasspath(
+    name = "platformclasspath_unstripped",
+    src = "DumpPlatformClassPath.java",
+    java_runtime_alias = ":current_java_runtime",
+    language_version_bootstrap_runtime = select({
+        ":incompatible_language_version_bootclasspath_enabled": ":language_version_bootstrap_runtime",
+        "//conditions:default": None,
+    }),
+    strip = False,
+)
+
 default_java_toolchain(
     name = "toolchain",
     configuration = DEFAULT_TOOLCHAIN_CONFIGURATION,
diff --git a/toolchains/bootclasspath.bzl b/toolchains/bootclasspath.bzl
index 5b4187c..945a73c 100644
--- a/toolchains/bootclasspath.bzl
+++ b/toolchains/bootclasspath.bzl
@@ -231,7 +231,7 @@
         input = unstripped_bootclasspath,
         output = bootclasspath,
     )
-
+    bootclasspath = bootclasspath if ctx.attr.strip else unstripped_bootclasspath
     return [
         DefaultInfo(files = depset([bootclasspath])),
         java_common.BootClassPathInfo(
@@ -256,6 +256,7 @@
             cfg = "exec",
             allow_single_file = True,
         ),
+        "strip": attr.bool(default = True),
         "_allowlist_function_transition": attr.label(
             default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
         ),
diff --git a/toolchains/default_java_toolchain.bzl b/toolchains/default_java_toolchain.bzl
index 5d1d54a..b08e491 100644
--- a/toolchains/default_java_toolchain.bzl
+++ b/toolchains/default_java_toolchain.bzl
@@ -143,6 +143,7 @@
     singlejar = [Label("@remote_java_tools//:singlejar_cc_bin")],
     header_compiler_direct = [Label("@remote_java_tools//:TurbineDirect")],
     oneversion = Label("@remote_java_tools//:one_version_cc_bin"),
+    bootclasspath = [Label("//toolchains:platformclasspath_unstripped")],
 )
 
 def default_java_toolchain(name, configuration = DEFAULT_TOOLCHAIN_CONFIGURATION, toolchain_definition = True, exec_compatible_with = [], target_compatible_with = [], **kwargs):