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

Abierto
#401 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
62/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
Java
Estrellas
73
Forks
38
Merge medio
12 h 32 min
PR fusionados (30 d)
45

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de liquid-java/liquidjava

Todos los issues de liquid-java/liquidjava

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.