-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: @AlwaysUnique (?) to mark classes whose instances must always be @Unique #3313
Comments
Thanks for the suggestion! However, I think the Aliasing Checker needs a few improvements to correctly work with this feature. import org.checkerframework.common.aliasing.qual.Unique;
import org.checkerframework.framework.qual.DefaultQualifierForUse;
@Unique
class Data {
@SuppressWarnings("unique.leaked")
Data() {}
}
class Demo {
void foo(Data p) {
Data y = p;
y.toString();
}
} Doesn't raise an error when the parameter is not annotated, but does when we add a The Also, by default the CF allows top annotations for local variables, which is not useful for this type system. So instead of adding a new annotation, we should look into making the upper bound feature work correctly for the Aliasing Checker. |
Yeah, most likely lifting this limitation of
coz then with |
Actually! even more prominent candidate for being marked as always |
This reverts commit fd536c4.
…ols#3313) using .astub files, with test cases
This reverts commit fd536c4.
This reverts commit fd536c4.
This reverts commit fd536c4.
This reverts commit fd536c4.
Checker: Aliasing Checker
Annotation name:
@AlwaysUnique
or@OnlyUnique
or@Require{d,s,}Unique
Annotation target: class and interface declarations
Proposed behavior:
All instances of the class/interface
X
marked (possibly via stubs) as@AlwaysUnique
must be@Unique
(i.e. no instance of@MaybeAliased X
type is ever allowed in the checked code).Use cases:
Certain mutable objects are inherently unsafe when leaked. A good example might be JGit's
org.eclipse.jgit.revwalk.RevCommit
(as of v5.7.0), which has a mutable internal state. When the instance is leaked, the original holder of the reference may experience an unexpected behavior unless it callsRevCommit#reset
.The text was updated successfully, but these errors were encountered: