Verifier crashes on a field or enum constant whose declaring class cannot be resolved
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 62/100
Hướng nghiên cứu
The crash is in Utils.qualifyFieldName (Utils.java, around line 56), reached from RefinementTypeChecker.visitCtFieldRead (line 325) when a CtFieldReference has a null declaring type. Start by running the four-line Repro class from the issue against the verifier and checking how the null case is handled for other field reads. Done means the reproducer prints the 'Passed Verification' result with the compilation warning instead of throwing, and the unresolved-type case is covered by a test.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Impact: verification stops with an internal error: 5 of the 53 real-world files below.
Description
Reading a field whose declaring type is unknown (an enum constant in a case label, a field generated by Lombok such as log, an array's .length on a value of an unresolved type): CtFieldReference.getDeclaringType() is null and Utils.qualifyFieldName calls getQualifiedName() on it.
Minimal reproducer (org.example.missing is not on the classpath)
import org.example.missing.Mode;
public class Repro {
static int weight(Mode mode) {
switch (mode) {
case STATEFUL:
return 2;
default:
return 1;
}
}
}
Expected
Correct! Passed Verification. (with the "Java compilation encountered issues" warning).
Actual
Exception in thread "main" java.lang.RuntimeException:
Error while checking CtMethodImpl
on weight(Mode mode) {
at Repro.java:4
with
Error while checking CtBlockImpl
on {
at Repro.java:4
with
Error while checking CtSwitchImpl
on switch (mode) {
at Repro.java:5
with
Error while checking CtCaseImpl
on case STATEFUL:
at Repro.java:6
with
Error while checking CtFieldReadImpl
on STATEFUL:
at Repro.java:6
with Cannot invoke "spoon.reflect.reference.CtTypeReference.getQualifiedName()" because the return value of "spoon.reflect.reference.CtFieldReference.getDeclaringType()" is null
at liquidjava.processor.refinement_checker.TypeChecker.scan(TypeChecker.java:80)
at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:189)
at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:154)
at spoon.reflect.visitor.CtScanner.visitCtClass(CtScanner.java:363)
at liquidjava.processor.refinement_checker.RefinementTypeChecker.visitCtClass(RefinementTypeChecker.java:97)
at spoon.support.reflect.declaration.CtClassImpl.accept(CtClassImpl.java:63)
at liquidjava.processor.RefinementProcessor.lambda$processPackage$3(RefinementProcessor.java:51)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at liquidjava.processor.RefinementProcessor.processPackage(RefinementProcessor.java:50)
at liquidjava.processor.RefinementProcessor.process(RefinementProcessor.java:35)
at liquidjava.processor.RefinementProcessor.process(RefinementProcessor.java:15)
at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:72)
at spoon.support.QueueProcessingManager.process(QueueProcessingManager.java:118)
at spoon.support.QueueProcessingManager.process(QueueProcessingManager.java:132)
at liquidjava.api.CommandLineLauncher.launch(CommandLineLauncher.java:92)
at liquidjava.api.CommandLineLauncher.main(CommandLineLauncher.java:41)
...
Caused by: java.lang.NullPointerException: Cannot invoke "spoon.reflect.reference.CtTypeReference.getQualifiedName()" because the return value of "spoon.reflect.reference.CtFieldReference.getDeclaringType()" is null
at liquidjava.utils.Utils.qualifyFieldName(Utils.java:56)
at liquidjava.processor.refinement_checker.RefinementTypeChecker.visitCtFieldRead(RefinementTypeChecker.java:325)
at liquidjava.processor.refinement_checker.TypeChecker.scan(TypeChecker.java:69)
Reproduced on main at dcfc4eb2 (liquidjava-verifier 0.0.35).
Real-world files that hit it
log.error("get host name error:{}", e.getMessage());— apache/ozhera (file)UNKNOWN_CASING;— apache/derby (file)(p.define().length > 0 || p.include().length > 0 || p.cinclude().length > 0 ||— larael/javacpp (file)STATEFUL:— stratwine/openejb (file)(config.httpAdminPassword.length() < MIN_ADMIN_PASSWORD_LENGTH) {— spazio17/muralis (file)
Context
Found while running LiquidJava on the original repository files of 53 real-world typestate and refinement bugs (the same files as our study exercises, before simplification). Each file is verified on its own, as a user would on one file of a project, so the project's other classes and its dependencies are not on the classpath. On main this crash and the two related ones (#388 binary operator, #389 unary operator, #390 field read) stop verification in 33 of the 53 files.
- Ngôn ngữ chính
- Java
- Star
- 67
- Fork
- 36
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 29
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 72/100
liquid-java/liquidjava#388 ·
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 65/100
liquid-java/liquidjava#373 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
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
-
Verifier crashes on `!` (or another unary operator) applied to a call whose type cannot be resolvedĐang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
liquid-java/liquidjava#389 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Synthesize hints for resolutionĐang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
liquid-java/liquidjava#381 ·
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
openhab/openhab-addons#21921 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
jellyfin/jellyfin-androidtv#5885 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
objectionary/eo-graphs#85 ·
-
XtYaml throws a bare ClassCastException when sheets or asserts is a scalar or holds a non-stringĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
objectionary/xax#246 ·
Maintainer thường phản hồi trong vòng 1 ngày