palantir / palantir-java-format

A modern, lambda-friendly, 120 character Java formatter.
Apache License 2.0
427 stars 46 forks source link

RemoveUnusedImports fails with NoSuchMethodError com.sun.tools.javac.tree.JCTree$JCImport.getQualifiedIdentifier() #916

Closed slachiewicz closed 1 year ago

slachiewicz commented 1 year ago

What happened?

Java 21 (Corretto) for the project https://github.com/codehaus-plexus/modello When I try to run spotless-maven-plugin:2.38.0:check (spotless-check) on project modello-core

Execution spotless-check of goal com.diffplug.spotless:spotless-maven-plugin:2.38.0:check failed: An API incompatibility was encountered while executing com.diffplug.spotless:spotless-maven-plugin:2.38.0:check: java.lang.NoSuchMethodError: 'com.sun.tools.javac.tree.JCTree com.sun.tools.javac.tree.JCTree$JCImport.getQualifiedIdentifier()'

with stacktrace Caused by: java.lang.NoSuchMethodError: 'com.sun.tools.javac.tree.JCTree com.sun.tools.javac.tree.JCTree$JCImport.getQualifiedIdentifier()' at com.palantir.javaformat.java.RemoveUnusedImports.getSimpleName (RemoveUnusedImports.java:245) at com.palantir.javaformat.java.RemoveUnusedImports.buildReplacements (RemoveUnusedImports.java:225) at com.palantir.javaformat.java.RemoveUnusedImports.removeUnusedImports (RemoveUnusedImports.java:209) at com.diffplug.spotless.glue.pjf.PalantirJavaFormatFormatterFunc.apply (PalantirJavaFormatFormatterFunc.java:42) at com.diffplug.spotless.FormatterFunc.apply (FormatterFunc.java:32)

Build with one of the latest Java 20 works fine in same environment.

What did you want to happen?

Have a possibility to uselib with soon to be released Java 21

slachiewicz commented 1 year ago

Duplicate of #909