Spec predicates cannot mention null: "Variable 'null' could not be found"
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start by running the DatagramSocketRefinements.java and Client.java reproducer to confirm that null in the predicate triggers the reported error. Then trace how the spec predicate is parsed and checked; the issue does not name those implementation files. Done means the reproducer verifies successfully and reports Correct! Passed Verification.
由索引模型根据 Issue 内容生成。
描述
Summary
A spec predicate cannot mention null: bindaddr == null ? ... : ... gives Not Found Error: Variable 'null' could not be found. So a spec cannot say what the JDK does when a parameter is null, even where that is the documented way to choose a state.
Minimal reproducer
DatagramSocketRefinements.java:
import java.net.SocketAddress;
import liquidjava.specification.*;
@ExternalRefinementsFor("java.net.DatagramSocket")
@StateSet({"unbound", "bound"})
public interface DatagramSocketRefinements {
@StateRefinement(to = "bindaddr == null ? unbound(this) : bound(this)")
void DatagramSocket(SocketAddress bindaddr);
@StateRefinement(from = "unbound(this)", to = "bound(this)")
void bind(SocketAddress addr);
}
Client.java:
import java.net.DatagramSocket;
import java.net.InetSocketAddress;
public class Client {
public static void main(String[] args) throws Exception {
DatagramSocket s = new DatagramSocket(null); // Variable 'null' could not be found
s.setReuseAddress(true);
s.bind(new InetSocketAddress(0));
s.close();
}
}
Expected: Correct! Passed Verification. On the JVM this runs: DatagramSocket(SocketAddress) says "if the address is null, creates an unbound socket", so that options such as setReuseAddress can be set before binding.
Seen on 1a506fe, f7f366c and main at 19991d3.
Why it matters: real code
Without null in predicates the spec has to pick one state for the constructor. Choosing bound (what every other constructor does) rejects the documented idiom above, which real UDP code uses. Two of five mined GitHub methods using DatagramSocket do exactly this: create with null, then bind(new InetSocketAddress(IP, port)) (e.g. Padawan-Transport-Protocol-PTP Sender.createSocket). Choosing unbound instead lets bind on an already-bound socket through, which throws SocketException on the JVM.
Found while checking mined client code against JDK specs (liquid-java/co-specification, verifier probe V34).
- 主要语言
- 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 天内回复