Soundness: a Java version set in the maven-compiler-plugin configuration is ignored, so declarations are dropped and verification passes

Ouverte
#401 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
62/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
java

Piste de recherche

Start in ComplianceLevel, where the Java version is read from the maven.compiler.release and maven.compiler.source properties of the nearest pom.xml. Recreate the reproducer from the issue (a pom with a maven-compiler-plugin <release>17</release> override and src/main/java/demo/Retry.java) and confirm that verification passes today. Done means the plugin configuration takes precedence, so the @Refinement on line 7 produces a Refinement Error. The second suggested fix, changing the warning behaviour, needs a maintainer decision and is out of scope for a first contribution.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug

Impact: a real bug passes verification (false negative), with only a warning. Found while investigating #342.

Description

ComplianceLevel reads the Java version only from the maven.compiler.release / maven.compiler.source properties of the nearest pom.xml that has one. A version set in the maven-compiler-plugin configuration (<release>, <source>) is ignored. When the properties say a lower version than the code needs, Spoon parses at that level, newer constructs are mis-parsed, and whole declarations disappear from the model. The run prints "Java compilation encountered issues" and then "Correct! Passed Verification."

Common setup: a parent pom with maven.compiler.source 1.8 and a module that overrides the version in its compiler-plugin configuration.

Minimal reproducer (directory with this pom.xml and src/main/java/demo/Retry.java)

<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>
  <groupId>demo</groupId><artifactId>demo</artifactId><version>1</version>
  <properties><maven.compiler.source>1.8</maven.compiler.source></properties>
  <build><plugins><plugin>
    <groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId>
    <configuration><release>17</release></configuration>
  </plugin></plugins></build>
</project>
package demo;

import liquidjava.specification.Refinement;

public record Retry(int attempts) {
    void fail() {
        @Refinement("_ > 0") int n = -1;
    }
}

Expected

A Refinement Error on line 7.

Actual (main ad055b49)

Warning: Java compilation encountered issues. Verification may be affected.

Correct! Passed Verification.

Possible fixes

  1. Read <release> / <source> from the maven-compiler-plugin configuration, giving it precedence over the properties as Maven does.
  2. More generally, do not report "Correct! Passed Verification." after compilation problems that may have dropped declarations (e.g. report them as errors, or say verification is incomplete). This changes what users see, including in the IDE, so it needs a decision.
Langage dominant
Java
Étoiles
73
Forks
38
Merge moyen
12 h 32 min
PR mergées (30 j)
45

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de liquid-java/liquidjava

Toutes les issues de liquid-java/liquidjava

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.