Description
We recently upgraded from Java 17 to Java 21. Apparently the JavaParser has a problem with switch over a sealed type.
- spotless 6.25.0 or 7.0.0.BETA1
- cleanthat 2.21
Error Message
There is no such thing as a local interface. Pay attention that this feature is supported starting from 'JAVA_16' language level. If you need that feature the language level must be configured in the configuration before parsing the source files.
Not able to parse path='Sample.java' with com.github.javaparser.JavaParser@200c1143
Code
public class Sample {
void sample() {
interface ISample {
void iSample();
}
}
}
How we include cleanthat into our build
We do specify Java 21 where we include cleanthat:
cleanthat()
.version("2.21")
.sourceCompatibility("21")
.addMutator("SafeButNotConsensual")
.excludeMutator("UseUnderscoresInNumericLiterals")
.excludeMutator("AvoidInlineConditionals")
I should probably also mention that cleanthat was updated to include JavaParser v3.26.1 following the issue #817
Maybe I should open a JavaParser issue instead?
Edit: Oh, there already is one: javaparser/javaparser#3990
Edit 2: That issue also mentions that the main developers of JavaParser are no longer active, and that there may be more up-to-date alternatives. This comment is marked as abuse though 🤔, so the link does not open the comment directly): It mentions this post which uses talks about https://github.com/congo-cc/congo-parser-generator