Unannotated methods of the same class: a parameter's state is unknown inside, and the method's effect is lost at the call site
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- java
- 领域
- compilers, testing-qa
调研方向
Start with the two-file Java reproducer in the issue and trace how private same-class methods are checked and how their effects are propagated at call sites. Compare the reported error inside rewind with the missing error after rewind(br); also consider the described exception and initCause case. Done means the reproducer reports no error inside rewind and flags the second br.reset().
由索引模型根据 Issue 内容生成。
描述
Impact: a false error inside a helper, and a missed bug at its call site.
Description
A private (or otherwise unannotated) method of the same class that takes a typestate object as a parameter is checked as if the parameter could be in any state, and its effect on the argument is not applied at the call site. In the reproducer:
- inside
rewind,r.reset()is reported ("found true but expected marked(r)") although its only caller marks the reader first; - at the call site,
bris still taken to bemarkedafterrewind(br), so the secondbr.reset(), which throws at run time, is not reported.
The same applies to objects that reach a method by other ways the file shows, e.g. an exception thrown by a method of the same class and caught by its caller: the catch parameter's state is unknown, so every initCause on it is reported, whether or not the thrower had set a cause.
Minimal reproducer (two files)
import liquidjava.specification.ExternalRefinementsFor;
import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;
@ExternalRefinementsFor("java.io.BufferedReader")
@StateSet({"open", "marked", "closed"})
interface BufferedReaderRefinements {
@StateRefinement(to = "open(this)")
void BufferedReader(java.io.Reader in);
@StateRefinement(from = "open(this)")
@StateRefinement(from = "marked(this)")
String readLine();
@StateRefinement(from = "open(this)", to = "marked(this)")
@StateRefinement(from = "marked(this)")
void mark(int readAheadLimit);
@StateRefinement(from = "marked(this)", to = "open(this)")
void reset();
@StateRefinement(from = "!closed(this)", to = "closed(this)")
void close();
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
public class Repro {
static void read(Reader in) throws IOException {
BufferedReader br = new BufferedReader(in);
br.mark(100);
rewind(br);
br.reset(); // rewind() already reset br, so it is no longer marked: not reported
}
private static void rewind(BufferedReader r) throws IOException {
r.reset(); // reported: "found true but expected marked(r)", though every caller here marks r first
}
}
Expected: no error inside rewind (every caller passes a marked reader), and an error at the second br.reset() in read.
Actual:
State Refinement Error: found true but expected marked(r²⁴)
14 | r.reset(); // reported: "found true but expected marked(r)", though every caller here marks r first
and nothing at line 10.
Possible directions: a way to write the state a parameter needs and leaves (e.g. @StateRefinement(from = "marked(r)", to = "open(r)") on the method), and/or inferring it for private methods of the same class from their bodies and call sites.
- 主要语言
- Java
- 星标
- 73
- 派生
- 38
- 平均合并
- 12 小时 32 分钟
- 30 天内合并 PR
- 45
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
liquid-java/liquidjava 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
liquid-java/liquidjava#562 ·
维护者通常 1 天内回复
-
A float ghost crashes the verifier: "Ghost not implemented for type float"可能已有人在做 @MohammedZaid1740 于 7 天前认领。 未关闭bug good first issue
难度 2/5 1-3 小时 新手友好度 72/100
liquid-java/liquidjava#443 · 1 条评论 ·
维护者通常 1 天内回复
-
bug real-world-finding
难度 2/5 1-3 小时 新手友好度 82/100
liquid-java/liquidjava#395 ·
维护者通常 1 天内回复
-
A ternary between arrays crashes: Sorts (Array Int Int) and Bool are incompatible可能已有人在做 @CatarinaGamboa 于 4 天前认领。 未关闭bug
难度 4/5 3-5 天 新手友好度 15/100
liquid-java/liquidjava#558 ·
维护者通常 1 天内回复
-
new T[a][b] gets length b instead of a (unsound)可能已有人在做 @CatarinaGamboa 于 4 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 30/100
liquid-java/liquidjava#557 ·
维护者通常 1 天内回复
查看 liquid-java/liquidjava 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 60/100
quelea-projection/Quelea#749 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 92/100
erkamyaman/rust-anything#963 ·
维护者通常 1 天内回复
-
api-diagnostics bug jdbc
难度 2/5 1-3 小时 新手友好度 75/100
ClickHouse/clickhouse-java#3464 ·
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 76/100
-
Deferred
难度 2/5 1-3 小时 新手友好度 78/100
Sanne/incus-spawn#2768 ·
维护者通常 1 天内回复