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