GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — java.removeUnusedImports does not handle import module correctly · Issue #2890 · diffplug/spotless

java.removeUnusedImports does not handle import module correctly #2890

New issue
Copy link
New issue
Copy link
Closed
#3008
Closed
java.removeUnusedImports does not handle import module correctly#2890
#3008
Copy link

Description

@sdavids
sdavids
opened on Mar 17, 2026
Issue body actions

pom.xml

  <properties>
    <maven.compiler.release>25</maven.compiler.release>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
          <java>
            <removeUnusedImports/>
          </java>
        </configuration>
      </plugin>
    </plugins>
  </build>

ModuleImportTest.java

import module java.base;

class ModuleImportTest {

  void test() {
    UUID.randomUUID();
  }
}

$ ./mvnw -v                     
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /Users/redacted/.m2/wrapper/dists/apache-maven-3.9.9/3477a4f1
Java version: 25.0.2, vendor: Eclipse Adoptium, runtime: /Users/redacted/.local/share/sdkman/candidates/java/25.0.2-tem
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "12.7.6", arch: "x86_64", family: "mac"

$ ./mvnw spotless:apply
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------< spotless:module-imports >-----------------
[INFO] Building module-imports 1.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- spotless:3.3.0:apply (default-cli) @ module-imports ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.126 s
[INFO] Finished at: 2026-03-17T10:30:13+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:3.3.0:apply (default-cli) on project module-imports: There were 1 lint error(s), they must be fixed or suppressed.
[ERROR]   src/main/java/ModuleImportTest.java:LINE_UNDEFINED removeUnusedImports(java.lang.IllegalArgumentException) object of type com.sun.tools.javac.tree.JCTree$JCModuleImport is not an instance of com.sun.tools.javac.tree.JCTree$JCImport (...)                                                                                                                                                                                                                                                 
[ERROR]   Resolve these lints or suppress with `<lintSuppressions>`
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Activity

  1. nedtwigg
    closed this as completedin 1a0d685on Aug 16, 2026
  2. pull
    added a commit that references this issue on Aug 16, 2026

    fix: support import module in removeUnusedImports via GJF 1.30.0

    This issue will close once commit 1a0d685 is merged into the 'main' branch.
    1a0d685
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.