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

Aberta
#401 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
62/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
java

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.
Linguagem predominante
Java
Estrelas
73
Forks
38
Merge médio
12h 32min
PRs com merge (30d)
45

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de liquid-java/liquidjava

Todas as issues de liquid-java/liquidjava

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.