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

未關閉
#401 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
62/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
java

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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.
主要語言
Java
星號
73
分支
38
平均合併
12 小時 32 分鐘
30 天內合併 PR
45

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

liquid-java/liquidjava 的其他 Issue

查看 liquid-java/liquidjava 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。