You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
expandWildcardImports issue for maven multi module projects #2946
When using expandWildcardImports, mvn spotless:apply fails for maven multi module projects with the following error:
[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:3.5.1:apply (default-cli) on project two: There were 1 lint error(s), they must be fixed or suppressed.
[ERROR] src/main/java/two/Two.java:LINE_UNDEFINED expandwildcardimports(java.lang.IllegalStateException) Symbol resolution not configured: to configure consider setting a SymbolResolver in the ParserConfiguration (...)
[ERROR] Resolve these lints or suppress with `<lintSuppressions>`
To reproduce:
git clone https://github.com/pdeneve/spotless-expand-wildcard-imports-issue.git
cd spotless-expand-wildcard-imports-issue
mvn spotless:apply
Thanks for the report and the minimal reproducer @pdeneve, that made this quick to track down!
The multi-module setup turned out to be incidental. The real trigger is that Two.java is a record. expandWildcardImports created its JavaParser at the library's default language level (Java 11), where records fail validation. JavaParser still returns a compilation unit in that case, but it only attaches the symbol resolver to successful parses, hence Symbol resolution not configured. Any wildcard import in a file using post-Java-11 syntax (records, sealed types, pattern-matching switches, …) would hit this, single-module too.
The fix parses at JavaParser's newest language level (the same one its JavaParserTypeSolver already uses for source roots). It also leaves a file unchanged instead of crashing if it still can't be parsed cleanly. A regression test mirrors your reproducer (module two depending on one, record Two(LocalDate date) with import java.time.*;). It failed with exactly your error before the change and passes after.
Activity
Pankraz76 commentedon Nov 7, 2026
Thanks for the report and the minimal reproducer @pdeneve, that made this quick to track down!
The multi-module setup turned out to be incidental. The real trigger is that
Two.javais arecord.expandWildcardImportscreated its JavaParser at the library's default language level (Java 11), where records fail validation. JavaParser still returns a compilation unit in that case, but it only attaches the symbol resolver to successful parses, henceSymbol resolution not configured. Any wildcard import in a file using post-Java-11 syntax (records, sealed types, pattern-matching switches, …) would hit this, single-module too.The fix parses at JavaParser's newest language level (the same one its
JavaParserTypeSolveralready uses for source roots). It also leaves a file unchanged instead of crashing if it still can't be parsed cleanly. A regression test mirrors your reproducer (moduletwodepending onone,record Two(LocalDate date)withimport java.time.*;). It failed with exactly your error before the change and passes after.Fix: #3173