Skip to content

Fix UseLambdaForFunctionalInterface for varargs - #1048

Merged
greg-at-moderne merged 1 commit into
mainfrom
greg-uselambda-aioobe-cast
Sep 3, 2026
Merged

Fix UseLambdaForFunctionalInterface for varargs#1048
greg-at-moderne merged 1 commit into
mainfrom
greg-uselambda-aioobe-cast

Conversation

@greg-at-moderne

@greg-at-moderne greg-at-moderne commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What's changed?

Fix UseLambdaForFunctionalInterface handling of varargs.

What's your motivation?

Otherwise it might fail with:

java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
  java.base/java.util.Arrays$ArrayList.get(Arrays.java:4225)
  org.openrewrite.staticanalysis.UseLambdaForFunctionalInterface$1.methodArgumentRequiresCast(UseLambdaForFunctionalInterface.java:249)
  org.openrewrite.staticanalysis.UseLambdaForFunctionalInterface$1.maybeAddCast(UseLambdaForFunctionalInterface.java:160)
  org.openrewrite.staticanalysis.UseLambdaForFunctionalInterface$1.convertToLambda(UseLambdaForFunctionalInterface.java:149)
  org.openrewrite.staticanalysis.UseLambdaForFunctionalInterface$1.visitNewClass(UseLambdaForFunctionalInterface.java:98)
  org.openrewrite.staticanalysis.UseLambdaForFunctionalInterface$1.visitNewClass(UseLambdaForFunctionalInterface.java:54)
  org.openrewrite.java.tree.J$NewClass.acceptJava(J.java:4839)
  org.openrewrite.java.tree.J.accept(J.java:55)
  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:242)
  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:328)
  org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1350)
  org.openrewrite.java.JavaVisitor.lambda$visitContainer$35(JavaVisitor.java:1400)
  org.openrewrite.internal.ListUtils.map(ListUtils.java:245)
  org.openrewrite.internal.ListUtils.map(ListUtils.java:269)
  org.openrewrite.java.JavaVisitor.visitContainer(JavaVisitor.java:1400)
  org.openrewrite.java.JavaVisitor.visitMethodInvocation(JavaVisitor.java:917)

@greg-at-moderne greg-at-moderne self-assigned this Sep 2, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Sep 2, 2026
@greg-at-moderne
greg-at-moderne marked this pull request as ready for review September 3, 2026 09:08
@greg-at-moderne
greg-at-moderne merged commit a79953c into main Sep 3, 2026
1 check passed
@greg-at-moderne
greg-at-moderne deleted the greg-uselambda-aioobe-cast branch September 3, 2026 09:08
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant