False error: a local declared inside try is "not found" at a call in finally
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start by reproducing the report: save the Repro class from the issue and run LiquidJava on it to see the Not Found Error at input.close() in the finally. The cause is that the state of input recorded at the end of the try still mentions the block-local length, which is out of scope when the finally checks close(). Done means the repro passes verification and the change does not break the existing tests.
由索引模型根据 Issue 内容生成。
描述
With the Barista BufferedInputStream spec (read() returns _ >= -1; read(byte[], int, int) refines its length):
import java.io.*;
public class Repro {
static int load(InputStream raw, boolean known) throws IOException {
BufferedInputStream input = new BufferedInputStream(raw);
try {
int cost = 0;
if (known) {
int length = input.read();
if (length >= 0) {
byte[] nonce = new byte[length];
input.read(nonce, 0, length);
}
}
return cost;
} finally {
input.close();
}
}
}
On main 1c6807be (and 321a7321):
Not Found Error: Variable 'length' could not be found
input.close(); (in the finally)
length is a block-local of the try; the state of input recorded in the try (after read(nonce, 0, length)) mentions it, and when the finally checks close() against that state, length is out of scope. Expected: Correct! Passed Verification. (out-of-scope locals should be eliminated or kept as fresh variables when the state flows into the finally / after the block).
Found in a real-code example (secrets-for-android FileUtils, a length-prefixed read in try/finally). Since #366 the example's earlier workaround (guarding with a block instead of an early return) no longer avoids it.
- 主要语言
- Java
- 星标
- 69
- 派生
- 36
- 平均合并
- 2 天 1 小时
- 30 天内合并 PR
- 35
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
liquid-java/liquidjava 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
liquid-java/liquidjava#395 ·
维护者通常 2 天内回复
-
Verifier crashes on a comparison or other binary operator whose operand types cannot be resolved (classes not on the classpath)可能已有人在做 @CatarinaGamboa 于 3 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
liquid-java/liquidjava#388 ·
维护者通常 2 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
liquid-java/liquidjava#373 ·
维护者通常 2 天内回复
-
Soundness: a local variable with a constant's name shadows the constant (Format.JPG read as local JPG)可能已有人在做 @CatarinaGamboa 于 3 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
liquid-java/liquidjava#321 ·
维护者通常 2 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 40/100
liquid-java/liquidjava#405 ·
维护者通常 2 天内回复
查看 liquid-java/liquidjava 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
apache/rocketmq-dashboard#6872 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
ADORSYS-GIS/token-status-link#168 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
ADORSYS-GIS/keycloak-oid4vp-plugin#232 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 62/100
devops-thiago/ThrillhouseBot#1132 ·
维护者通常 1 天内回复