External specs do not reach user subclasses: a typestate call on a subclass receiver crashes with a sort mismatch
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #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時間
- マージ済み PR(30日)
- 28
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 25/100
liquid-java/liquidjava#381 ·
メンテナーはふだん 1 日以内に返信
-
enhancement future latte
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
liquid-java/liquidjava#380 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
liquid-java/liquidjava#379 ·
メンテナーはふだん 1 日以内に返信
liquid-java/liquidjava の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
team:Lumberjack
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
OpenLiberty/open-liberty#35998 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] SQS SendMessageBatch accepts more than 10 entries instead of TooManyEntriesInBatchRequestオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
floci-io/floci#5319 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Bug QWP
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100