ASSERT-KTH / spork

AST-based structured merge tool for Java, fully Git compatible https://doi.org/10.1109/TSE.2022.3143766
MIT License
53 stars 8 forks source link

Java 21 support #479

Open wetneb opened 9 months ago

wetneb commented 9 months ago

Running mvn clean test with Java 21, I get various module-related errors, such as this one:

[ERROR] mergeTreeShouldEqualReParsedPrettyPrent_whenBothRevisionsAreModified{TestSources, Path}[14]  Time elapsed: 0.023 s  <<< ERROR!
java.lang.ClassCastException: class spoon.reflect.factory.ModuleFactory$CtUnnamedModule cannot be cast to class spoon.reflect.declaration.CtType (spoon.reflect.factory.ModuleFactory$CtUnnamedModule and spoon.reflect.declaration.CtType are in unnamed module of loader 'app')
    at se.kth.spork.cli.CliTest.runTestMerge(CliTest.java:139)
    at se.kth.spork.cli.CliTest.mergeTreeShouldEqualReParsedPrettyPrent_whenBothRevisionsAreModified(CliTest.java:91)

There might be some command line options to add to open the required modules.

monperrus commented 9 months ago

thanks for the report, would you be able to PR?

slarse commented 9 months ago

Spork is only known to run really well with Java 11, and on Java 11 code. There's syntax in later versions of Java that Spork does not support merging. As long as that syntax isn't used in the source code it should in theory be possible to use Spork on later versions of Java, though, but then Spoon needs to be updated.

Spork is about 2 years out of date with Spoon versions and there are many breaking changes in later versions of gumtree/gumtree-spoon (which would also need to be updated to update spoon itself). Due to the nature of Spork, it relies uncomfortably much on implementation details of libraries (Spoon and gumtree-spoon) that themselves rely on implementation details of the JVM, so updating to later versions is quite a bit of work and requires quite a bit of tuning.

I'd be happy to see updates to the core dependencies but my time for such is unfortunately too limited to start up right now.

wetneb commented 9 months ago

Good to know that it's a significant task! The error message mentions modules but after a bit of googling it seems that it's not actually related to the JPMS indeed.