Bazel: Limit JDK removal warnings to first-party Java code

JDK 25+ can expose or surface javac removal warnings more aggressively,
causing Bazel builds to report [removal] warnings from external
dependencies such as protobuf.

Because these are standard javac lint warnings rather than Error Prone
checks, package-scoped Error Prone configurations do not suppress them.

To fix this:
- Add "-Xlint:-removal" globally to the toolchain's javacopts.
- Re-enable "-Xlint:removal" specifically for Gerrit's first-party
  packages using a dedicated java_package_configuration.

This preserves important removal diagnostics for first-party code while
keeping external dependencies quiet.

Release-Notes: skip
Change-Id: I03547b34badd768b7eadd5cc60e507727e7709b9
diff --git a/tools/BUILD b/tools/BUILD
index 31aa465..a2fed1b 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -27,8 +27,12 @@
     # methods that require this JVM flag on JDK 24+.
     # See: protocolbuffers/protobuf#20760.
     javabuilder_jvm_opts = ["--sun-misc-unsafe-memory-access=allow"] if int(VERSION) >= 24 else [],
+    javacopts = [
+        "-Xlint:-removal",
+    ],
     package_configuration = [
         ":error_prone",
+        ":first_party_removal_warnings",
     ],
     source_version = VERSION,
     target_version = VERSION,
@@ -456,7 +460,15 @@
         "-Xep:ZoneIdOfZ:ERROR",
         "-Xlint:unchecked",
     ],
-    packages = ["error_prone_packages"],
+    packages = [":error_prone_packages"],
+)
+
+java_package_configuration(
+    name = "first_party_removal_warnings",
+    javacopts = [
+        "-Xlint:removal",
+    ],
+    packages = [":error_prone_packages"],
 )
 
 package_group(