Nested classes wipe the outer class's field refinements
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #326 của @rcosta358 — đã merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start in RefinementTypeChecker.visitCtClass and MethodsFirstChecker.visitCtClass, focusing on how context.reinitializeContext() changes ctxVars while Spoon visits nested classes. Use the OuterWiped reproducer to verify that the outer field refinement remains available after Inner, while writes such as x = -1 are still rejected. Done means the reproducer passes verification without losing the existing write check.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Entering a nested class resets the variable context, which wipes the outer class's fields. Any method of the outer class declared after a nested class loses the refinements of the outer class's own fields.
Minimal reproducer
import liquidjava.specification.Refinement;
public class OuterWiped {
@Refinement("_ > 0") int x = 1;
static class Inner { int y; }
@Refinement("_ > 0")
public int get() { return x; }
}
Expected
Correct! Passed Verification.
Actual
Refinement Error: true is not a subtype of #ret¹ > 0
6 | public int get() { return x; }
| ^^^^^^^^^
--> Not enough information to prove the expected refinement. Add a refinement or condition to constrain it.
Removing Inner (or moving it below get) makes it pass. Writes such as x = -1 are still rejected correctly, because the expected refinement is read from the field's annotation.
Cause
RefinementTypeChecker.visitCtClass (and MethodsFirstChecker.visitCtClass) call context.reinitializeContext(), which clears ctxVars. Spoon visits nested classes as children of the outer class, so visiting Inner clears this#x. The opposite also happens: the nested class's fields stay in the context after it returns. That leak is why declaring a nested class before its use works today (see #308).
Possible fix
When a class is entered, register all of its fields (and those of its nested types) before visiting any methods, and keep nested classes from clearing the enclosing class's context. This would probably also fix the read case above.
Reproduced on main at fbfb4e23 (liquidjava-verifier 0.0.35).
- Ngôn ngữ chính
- Java
- Star
- 67
- Fork
- 36
- Merge trung bình
- 2 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 24
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của liquid-java/liquidjava
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
liquid-java/liquidjava#321 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Soundness: try/catch is checked as if the catch block always runsCó thể đã có người làm @CatarinaGamboa đã nhận 1 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
liquid-java/liquidjava#364 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 66/100
liquid-java/liquidjava#360 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
External specs do not reach user subclasses: a typestate call on a subclass receiver crashes with a sort mismatchCó thể đã có người làm @CatarinaGamboa đã nhận 1 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
liquid-java/liquidjava#353 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 55/100
liquid-java/liquidjava#349 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của liquid-java/liquidjava
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
NationalSecurityAgency/ghidra#9748 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
spring-mcp-tools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
explyt/spring-plugin#591 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
waiting-for-triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
spring-cloud/spring-cloud-openfeign#1443 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
ADORSYS-GIS/keycloak-oid4vp-plugin#221 ·
Maintainer thường phản hồi trong vòng 2 ngày