You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Checker Framework throws an AssertionError when attempting to infer the @Owning annotation for fields with a @MustCallUnknown annotation. This occurs during the processing of generic class fields when the MustCallInference method incorrectly handles fields marked as @MustCallUnknown, leading to a failure in the assertion due to both @CalledMethods({}) and mustCallValues being empty.
Run the Checker Framework (version 3.43.0-SNAPSHOT) on this file with the Resource Leak Checker enabled. Or run the resource leak inference test suite.
./gradlew AinferResourceLeakAjavaTest
Expected Behavior:
The Checker Framework should either correctly infer the @Owning annotation for fields marked as @MustCallUnknown or conservatively avoid inferring an @Owning annotation to prevent an AssertionError.
Actual Behavior:
The Checker Framework crashes with an AssertionError, indicating a failure to handle @MustCallUnknown fields correctly during the inference process.
The method MustCallInference::inferOwningField incorrectly assumes that a field with a @MustCallUnknown annotation can have a non-empty must-call obligation. This leads to an assertion failure when both the called methods annotation (cmAnno) and the must-call values (mustCallValues) are empty, despite passing the must-call consistency check.
Proposed Solution:
Modify the ResourceLeakAnnotatedTypeFactory::isFieldWithNonemptyMustCallValue method to return false for fields whose MC type is @MustCallUnknown. This change will conservatively avoid inferring an @Owning annotation. Thus, avoiding incorrectly inferring an @Owning annotation for fields marked as @MustCallUnknown, addressing the assertion error.
Description:
The Checker Framework throws an AssertionError when attempting to infer the
@Owning
annotation for fields with a@MustCallUnknown
annotation. This occurs during the processing of generic class fields when the MustCallInference method incorrectly handles fields marked as@MustCallUnknown
, leading to a failure in the assertion due to both @CalledMethods({}) and mustCallValues being empty.Steps to Reproduce:
Create a Java file with the following content:
Run the Checker Framework (version 3.43.0-SNAPSHOT) on this file with the Resource Leak Checker enabled. Or run the resource leak inference test suite.
Expected Behavior:
The Checker Framework should either correctly infer the
@Owning
annotation for fields marked as@MustCallUnknown
or conservatively avoid inferring an@Owning
annotation to prevent an AssertionError.Actual Behavior:
The Checker Framework crashes with an AssertionError, indicating a failure to handle
@MustCallUnknown
fields correctly during the inference process.Stack Trace:
Analysis:
The method
MustCallInference::inferOwningField
incorrectly assumes that a field with a@MustCallUnknown
annotation can have a non-empty must-call obligation. This leads to an assertion failure when both the called methods annotation (cmAnno
) and the must-call values (mustCallValues
) are empty, despite passing the must-call consistency check.Proposed Solution:
Modify the
ResourceLeakAnnotatedTypeFactory::isFieldWithNonemptyMustCallValue
method to returnfalse
for fields whose MC type is@MustCallUnknown
. This change will conservatively avoid inferring an@Owning
annotation. Thus, avoiding incorrectly inferring an@Owning
annotation for fields marked as@MustCallUnknown
, addressing the assertion error.Environment:
Checker Framework Version: 3.43.0-SNAPSHOT
Java Version: JDK 8
The text was updated successfully, but these errors were encountered: