External specs do not reach user subclasses: a typestate call on a subclass receiver crashes with a sort mismatch
維護者通常 1 天內回覆
已經有一個關聯 PR 被合併了。
- #354 來自 @CatarinaGamboa —— 已合併
評估
研究方向
Start from RefinedVariable (how it records superclass/interface relations) and RefinementProcessor (its first pass processes types one by one), the two components named in the Causes section. Reproduce with the Repro/AppException example on main to see the sort mismatch, then trace where the state function argument sort is chosen for a subclass receiver. Done looks like the subclass case reporting State Refinement Error: found withThrowable(e) but expected noThrowable(e) instead of crashing — but note open PR #354 is already addressing this, so coordinate before starting.
由索引模型根據 Issue 內容生成。
描述
An external spec written for a class (@ExternalRefinementsFor("java.lang.Throwable")) does not reach user subclasses. A typestate call on a subclass receiver makes the verifier crash instead of reporting the violation.
Example
Spec (abridged from the Barista Throwable spec):
@ExternalRefinementsFor("java.lang.Throwable")
@StateSet({"noThrowable", "withThrowable"})
public interface ThrowableRefinements {
@StateRefinement(to = "noThrowable(this)") void Throwable(String message);
@StateRefinement(to = "withThrowable(this)") void Throwable(String message, Throwable cause);
@StateRefinement(from = "noThrowable(this)", to = "withThrowable(this)") Throwable initCause(Throwable cause);
}
Client code (a real bug shape: initCause on an exception whose cause was already set throws IllegalStateException: Can't overwrite cause):
public class Repro {
static class AppException extends RuntimeException {
AppException(String message, Throwable cause) { super(message, cause); }
}
static AppException wrap(Exception underlying, Exception detail) {
AppException e = new AppException("operation failed", underlying);
e.initCause(detail); // throws at runtime
return e;
}
}
On main (be47cb68):
Error: Sort mismatch at argument #1 for function (declare-fun java.lang.Throwable.state1 (java.lang.Throwable) Int) supplied sort is Repro$AppException
The same code with Throwable e = new Throwable("operation failed", underlying); is reported as intended:
State Refinement Error: found withThrowable(e) but expected noThrowable(e)
Causes
RefinedVariablerecords only the direct superclass and the direct interfaces, soAppExceptionis never related toThrowable(two levels up), and the state function's argument sort does not match.- A user constructor that delegates to
super(...)gets the default state rather than the state the super constructor's spec gives. RefinementProcessorruns the first pass type by type, so a user class can be processed before the external spec it depends on is registered.
Found while building exercises from real Java bugs (e.g. the "Can't overwrite cause" bugs in Apache projects), where a custom exception subclass is the usual shape.
- 主要語言
- Java
- 星號
- 67
- 分支
- 36
- 平均合併
- 2 天 4 小時
- 30 天內合併 PR
- 28
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
liquid-java/liquidjava 的其他 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 65/100
liquid-java/liquidjava#373 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
liquid-java/liquidjava#321 ·
維護者通常 1 天內回覆
-
enhancement
難度 5/5 一週以上 新手友好度 25/100
liquid-java/liquidjava#381 ·
維護者通常 1 天內回覆
-
enhancement future latte
難度 5/5 一週以上 新手友好度 35/100
liquid-java/liquidjava#380 ·
維護者通常 1 天內回覆
-
An external spec cannot refine methods its class inherits可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉bug
難度 4/5 3-5 天 新手友好度 48/100
liquid-java/liquidjava#379 ·
維護者通常 1 天內回覆
查看 liquid-java/liquidjava 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
Netcracker/qubership-integration-platform#1046 ·
維護者通常 2 天內回覆
-
`check_java_version()` fails when Java path contains spaces (Windows / Git Bash, `C:\Program Files`)未關閉
難度 2/5 1-3 小時 新手友好度 68/100
-
Fix Math.ceilDiv wrong result for exact positive divisions可能已有人在做 @pamod-madubashana 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 88/100
scala-native/scala-native#5094 ·
維護者通常 1 天內回覆
-
[Bug] AI unread message badge counts a batch of new bubbles as one message可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 74/100
apache/rocketmq-dashboard#5784 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
PCL-Community/PCL-CE#3658 ·
維護者通常 1 天內回覆