From 4b35a05cc83b98aa7e04ffd5eeeccf32cba450b7 Mon Sep 17 00:00:00 2001 From: hvadehra Date: Thu, 31 Oct 2024 16:52:52 +0100 Subject: [PATCH] [7.4.1] Add missing private API for tokenizing javacopts (#24153) PiperOrigin-RevId: 587638256 Change-Id: I4aa6b9c2009323e9c4adc7f6e8b5e335a637ed1c (cherry picked from commit fb446e6366b50a93f794118cb3b77bb55f189325) --- .../devtools/build/lib/rules/java/JavaStarlarkCommon.java | 6 ++++++ .../build/lib/starlarkbuildapi/java/JavaCommonApi.java | 6 ++++++ .../devtools/build/lib/rules/java/JavaStarlarkApiTest.java | 1 + 3 files changed, 13 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaStarlarkCommon.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaStarlarkCommon.java index 015c5893627a1a..68ab4a3723eede 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaStarlarkCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaStarlarkCommon.java @@ -472,6 +472,12 @@ public Sequence expandJavaOpts( } } + @Override + public Sequence tokenizeJavacOpts(Sequence opts) throws EvalException { + return StarlarkList.immutableCopyOf( + JavaHelper.tokenizeJavaOptions(Sequence.noneableCast(opts, String.class, "opts"))); + } + static boolean isInstanceOfProvider(Object obj, Provider provider) { if (obj instanceof NativeInfo) { return ((NativeInfo) obj).getProvider().getKey().equals(provider.getKey()); diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCommonApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCommonApi.java index 4dbe47ff74d7a4..69e66f959be01f 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCommonApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCommonApi.java @@ -751,4 +751,10 @@ JavaInfoT wrapJavaInfo(Info javaInfo, StarlarkThread thread) Sequence expandJavaOpts( StarlarkRuleContextT ctx, String attr, boolean tokenize, boolean execPaths) throws EvalException, InterruptedException; + + @StarlarkMethod( + name = "tokenize_javacopts", + documented = false, + parameters = {@Param(name = "opts")}) + Sequence tokenizeJavacOpts(Sequence opts) throws EvalException, InterruptedException; } diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/JavaStarlarkApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/JavaStarlarkApiTest.java index 4f705ac9da5761..b1821d5a6c817b 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/java/JavaStarlarkApiTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/java/JavaStarlarkApiTest.java @@ -3752,6 +3752,7 @@ public void testNoArgsPrivateAPIsAreIndeedPrivate(String module, String api) thr "{api: _incompatible_depset_for_java_output_source_jars}", "{api: wrap_java_info}", "{api: intern_javac_opts}", + "{api: tokenize_javacopts}", }) public void testJavaCommonPrivateApis_areNotVisibleToPublicStarlark(String api) throws Exception { // validate that this api is present on the module, so this test fails when the API is deleted