Repository navigation
Read Spoon compliance level from the project's pom.xml - #352
Open
CatarinaGamboa wants to merge 3 commits into
Open
CatarinaGamboa wants to merge 3 commits into
CatarinaGamboa wants to merge 3 commits into
Conversation
At level 8, Java 9+ syntax (`var`, `try (r)`, switch expressions) fails to compile, so verification runs on a broken model (e.g. `var` becomes a class `testSuite.var`). 17 is the highest level Spoon 10.4.2's JDT accepts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Should this be a cli flag? or read from maven? |
Collaborator
Author
|
I can check that but im not sure if all versions are supported by spoon |
Spoon's compliance level is now taken from the nearest pom.xml of the verified paths (compiler plugin release/source, then the maven.compiler.release/source properties, walking up to enclosing poms). It defaults to 19 when no pom declares one and is capped at 19, the highest level Spoon 10.4.2's JDT accepts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CatarinaGamboa
commented
Oct 7, 2026
| return Optional.empty(); | ||
| } | ||
| } | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
this file is HUGE for what it is doing, I trust that you can make something much much more contained! We can also import something to read the POM if needed, im sure there are libraries for that
| writePom(project, "<maven.compiler.release>25</maven.compiler.release>", null); | ||
| assertEquals(ComplianceLevel.MAX_SUPPORTED, ComplianceLevel.resolve(source().toString())); | ||
| } | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
we dont need as many tests i believe
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CommandLineLaunchersets Spoon's compliance level to 8, so any Java 9+ syntax fails to compile and LiquidJava verifies a broken model with only a generic warning ("Java compilation encountered issues"). E.g.var n = 5;is read as a variable of classtestSuite.var(Sorts testSuite.var and Int are incompatible), andtry (r)(Java 9 resource reference) does not parse, which blocks the second reproducer of #334.Change
ComplianceLevelreads the level from themaven.compiler.release(ormaven.compiler.source) property of the nearestpom.xmlof each verified path, walking up to enclosing poms, using the existingmaven-modeldependency.1.8is read as8; with several paths the highest level wins.20throwsUnrecognized option : -20). The cap is silent (the level is printed with--debug), since e.g.liquidjava-exampledeclares 20 and a warning would show up on every run.CorrectModernJavaSyntax(var,try (r), switch expression): fails at level 8, passes now.TestComplianceLevel(reads the pom, caps).Not read (falls back to 19): the compiler plugin's
<release>/<source>config, parents outside the enclosing directories, Gradle builds. Upgrading to Spoon 11.5 (levels up to 26) is in #363.Testing
mvn test: 369/369 pass.🤖 Generated with Claude Code