Skip to content

Handle GString compiler args in Gradle plugin#968

Merged
jupblb merged 1 commit into
mainfrom
michal/fix-2
Jul 2, 2026
Merged

Handle GString compiler args in Gradle plugin#968
jupblb merged 1 commit into
mainfrom
michal/fix-2

Conversation

@jupblb

@jupblb jupblb commented Jul 2, 2026

Copy link
Copy Markdown
Member

Fixes #801

Groovy build scripts that append interpolated strings to compiler args (options.compilerArgs << "${...}") put GStringImpl objects into the list. The plugin's duplicate-check args.stream().anyMatch(arg -> arg.startsWith("-Xplugin:scip")) on a List<String> inserts an erasure-driven checked cast to String per element, throwing:

ClassCastException: class org.codehaus.groovy.runtime.GStringImpl cannot be cast to class java.lang.String

The fix iterates compilerArgs through a List<?> reference and compares via String.valueOf(arg), so no element is ever cast to String. (Casting inside the lambda body would not help: the erased Predicate.test(Object) bridge casts the argument before the body runs.)

Includes a regression fixture (gradle/gstring-compiler-args) that appends a GString to compilerArgs; without the fix it fails with the exact error from the issue, with the fix all GradleBuildToolTest tests pass.

@jupblb jupblb merged commit c1aa242 into main Jul 2, 2026
23 checks passed
@jupblb jupblb deleted the michal/fix-2 branch July 2, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClassCastException: org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String in Gradle build

1 participant