Migrate the `JavaStarlarkApiTest.javaCommonCompile_requiresJavaPluginInfo` test to Starlark

The test is removed from Bazel and added in `@rules_java`

PiperOrigin-RevId: 738313270
Change-Id: I966643c3905a9f5f02fc717d932a46bf08b11df7
diff --git a/java/test/common/java_common_tests.bzl b/java/test/common/java_common_tests.bzl
index b8c1676..2b594b0 100644
--- a/java/test/common/java_common_tests.bzl
+++ b/java/test/common/java_common_tests.bzl
@@ -14,6 +14,7 @@
 load("//java/test/testutil:rules/custom_library_with_bootclasspath.bzl", "custom_bootclasspath", "custom_library_with_bootclasspath")
 load("//java/test/testutil:rules/custom_library_with_exports.bzl", "custom_library_with_exports")
 load("//java/test/testutil:rules/custom_library_with_sourcepaths.bzl", "custom_library_with_sourcepaths")
+load("//java/test/testutil:rules/custom_library_with_wrong_plugins_type.bzl", "custom_library_with_wrong_plugins_type")
 
 def _test_compile_default_values(name):
     util.helper_target(custom_library, name = name + "/custom", srcs = ["Main.java"])
@@ -426,6 +427,32 @@
     env.expect.that_collection(result.transitive_source_jars.to_list()).has_size(3)
     env.expect.that_collection(result.transitive_source_jars.to_list()).contains(result.source_jar)
 
+def _test_compile_requires_java_plugin_info(name):
+    target_name = name + "/to_be_processed"
+    util.helper_target(
+        java_library,
+        name = target_name + "/dep",
+        srcs = ["ProcessorDep.java"],
+    )
+    util.helper_target(
+        custom_library_with_wrong_plugins_type,
+        name = target_name,
+        srcs = ["ToBeProcessed.java"],
+        deps = [target_name + "/dep"],
+    )
+
+    analysis_test(
+        name = name,
+        impl = _test_compile_requires_java_plugin_info_impl,
+        target = target_name,
+        expect_failure = True,
+    )
+
+def _test_compile_requires_java_plugin_info_impl(env, target):
+    env.expect.that_target(target).failures().contains_predicate(
+        matching.str_matches("at index 0 of plugins, got element of type JavaInfo, want JavaPluginInfo"),
+    )
+
 def java_common_tests(name):
     test_suite(
         name = name,
@@ -443,5 +470,6 @@
             _test_compile_sets_runtime_deps,
             _test_compile_exposes_annotation_processing_info,
             _test_java_library_exposes_annotation_processing_info,
+            _test_compile_requires_java_plugin_info,
         ],
     )
diff --git a/java/test/testutil/rules/custom_library_with_wrong_plugins_type.bzl b/java/test/testutil/rules/custom_library_with_wrong_plugins_type.bzl
new file mode 100644
index 0000000..1253530
--- /dev/null
+++ b/java/test/testutil/rules/custom_library_with_wrong_plugins_type.bzl
@@ -0,0 +1,24 @@
+"""Custom rule to test java_common.compile(plugins = ...) expects JavaPluginInfo"""
+
+load("//java:defs.bzl", "JavaInfo", "java_common")
+load("//java/common:java_semantics.bzl", "semantics")
+
+def _impl(ctx):
+    output_jar = ctx.actions.declare_file("lib" + ctx.label.name + ".jar")
+    return java_common.compile(
+        ctx,
+        source_files = ctx.files.srcs,
+        plugins = [p[JavaInfo] for p in ctx.attr.deps],
+        output = output_jar,
+        java_toolchain = semantics.find_java_toolchain(ctx),
+    )
+
+custom_library_with_wrong_plugins_type = rule(
+    implementation = _impl,
+    attrs = {
+        "srcs": attr.label_list(allow_files = [".java"]),
+        "deps": attr.label_list(),
+    },
+    toolchains = [semantics.JAVA_TOOLCHAIN_TYPE],
+    fragments = ["java"],
+)