Skip to content

Fix RemoveUnusedImports crash on static wildcard from capitalized packages - #8655

Open
kalayciburak wants to merge 1 commit into
openrewrite:mainfrom
kalayciburak:fix/remove-unused-imports-static-wildcard-capitalized-package
Open

Fix RemoveUnusedImports crash on static wildcard from capitalized packages#8655
kalayciburak wants to merge 1 commit into
openrewrite:mainfrom
kalayciburak:fix/remove-unused-imports-static-wildcard-capitalized-package

Conversation

@kalayciburak

@kalayciburak kalayciburak commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What's changed?

Unfold a static star import using the fuzzy type-name match when getTypeName() treats a capitalized package segment as a nested class. That lookup used to miss, leave the unfolded list empty, and throw IndexOutOfBoundsException. The empty-list write is also skipped, matching the non-static wildcard branch.

What's your motivation?

Have you considered any alternatives or workarounds?

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've run ./gradlew :rewrite-java-test:test --tests org.openrewrite.java.RemoveUnusedImportsTest locally (77 tests, 2 skipped, 0 failures). No recipes.csv change.
  • I've formatted the lines I changed, without reformatting code I didn't touch

…kages

Unfold using the fuzzy type-name match when getTypeName() treats a
capitalized package segment as a nested class, and skip the empty-list
write that threw IndexOutOfBoundsException.

Fixes openrewrite#8654
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

RemoveUnusedImports throws IndexOutOfBoundsException unfolding a static wildcard import from a package with a capitalized segment

1 participant