Remove support for empty jars attribute from java_import

RELNOTES: java_import.jars attributes can no longer be empty, and --noincompatible_disallow_java_import_empty_jars is no longer supported
PiperOrigin-RevId: 756947066
Change-Id: I367ea741f95aeee4c26e7ad5e861b18f1da32725
diff --git a/java/common/rules/impl/bazel_java_import_impl.bzl b/java/common/rules/impl/bazel_java_import_impl.bzl
index f018fe7..4465670 100644
--- a/java/common/rules/impl/bazel_java_import_impl.bzl
+++ b/java/common/rules/impl/bazel_java_import_impl.bzl
@@ -71,14 +71,8 @@
         fail("java_import.exports is no longer supported; use java_import.deps instead")
 
 def _check_empty_jars_error(ctx, jars):
-    # TODO(kotlaja): Remove temporary incompatible flag [disallow_java_import_empty_jars] once migration is done.
-    if len(jars) > 0:
-        return  # jars is non empty
-    if not ctx.fragments.java.disallow_java_import_empty_jars():
-        return  # check disabled by flag
-    if hasattr(ctx.attr, "_allowlist_java_import_empty_jars") and getattr(ctx.attr, "_allowlist_java_import_empty_jars")[PackageSpecificationInfo].contains(ctx.label):
-        return  # allowlisted
-    fail("empty java_import.jars is no longer supported " + ctx.label.package)
+    if len(jars) == 0:
+        fail("empty java_import.jars is not supported " + ctx.label.package)
 
 def _create_java_info_with_dummy_output_file(ctx, srcjar, all_deps, exports, runtime_deps_list, neverlink, cc_info_list, add_exports, add_opens):
     dummy_jar = ctx.actions.declare_file(ctx.label.name + "_dummy.jar")
diff --git a/test/java/common/rules/java_import_tests.bzl b/test/java/common/rules/java_import_tests.bzl
index 680136a..8580c1d 100644
--- a/test/java/common/rules/java_import_tests.bzl
+++ b/test/java/common/rules/java_import_tests.bzl
@@ -424,30 +424,6 @@
         "{package}/somelib-src.jar",
     ])
 
-def _test_permits_empty_jars_with_flag(name):
-    if not bazel_features.rules.analysis_tests_can_transition_on_experimental_incompatible_flags:
-        # exit early because this test case would be a loading phase error otherwise
-        always_passes(name)
-        return
-
-    util.helper_target(
-        java_import,
-        name = name + "/rule",
-        jars = [],
-    )
-
-    analysis_test(
-        name = name,
-        impl = _test_permits_empty_jars_with_flag_impl,
-        target = name + "/rule",
-        config_settings = {
-            "//command_line_option:incompatible_disallow_java_import_empty_jars": False,
-        },
-    )
-
-def _test_permits_empty_jars_with_flag_impl(_env, _target):
-    pass
-
 def _test_disallows_empty_jars(name):
     if not bazel_features.rules.analysis_tests_can_transition_on_experimental_incompatible_flags:
         # exit early because this test case would be a loading phase error otherwise
@@ -472,7 +448,7 @@
 
 def _test_disallows_empty_jars_impl(env, target):
     env.expect.that_target(target).failures().contains_predicate(
-        matching.str_matches("empty java_import.jars is no longer supported"),
+        matching.str_matches("empty java_import.jars is not supported"),
     )
 
 def _test_disallows_files_in_exports(name):
@@ -964,7 +940,6 @@
             _test_transitive_dependencies,
             _test_exposes_java_provider,
             _test_jars_allowed_in_srcjar,
-            _test_permits_empty_jars_with_flag,
             _test_disallows_empty_jars,
             _test_disallows_files_in_exports,
             _test_disallows_arbitrary_files,