-
Notifications
You must be signed in to change notification settings - Fork 437
RLC extension for resource collection #7602
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
base: master
Are you sure you want to change the base?
Changes from 250 commits
7fd44cc
f3442c3
eb46285
3dfe32b
5474b79
4700443
410f092
77d6946
01ae15c
d7e3c0c
a201ecb
620b82e
3181578
08a7c08
076f0b7
b386e9e
b9bf410
fcf9e05
fab3eb9
dd92896
6a46cfb
56e8fd4
627cc6e
0a7d4f2
ffd8f25
d935a35
23a2fcd
c8d95a0
8ddb042
a62bede
5f32f89
ab5b2a2
9e3c23a
bbb7ef8
3ade7ed
62c4299
66901ee
be87c39
79506bd
71ae840
b1687a6
2b13a8d
518e749
fe206ee
4c3dc9c
14d37bf
82717fc
f474bc5
398d16c
f30abbb
80cd91a
b10609c
9a4d4ef
33d7b64
3347442
555194e
0f25e74
a4f1a3f
64b1855
03efa5f
4433b46
ffa65ba
b39a77a
fe92dab
10a30c2
eaadec9
ceebfff
6e95c34
9549bfc
116f596
6b0b327
346b9ed
a012a9d
96bd8a1
a961341
5d55958
9a0246b
7db0254
83fed79
b343553
20aa7d7
13c41f0
94c2730
76358b6
0e80e9d
41396e0
a00e883
2e81982
37c76a5
66d4ca8
a6e60b7
6f47713
8c1d87a
f9da2da
f4d47c6
eaa5492
e3e06d9
596f2e1
6b17e65
dada8a3
7bcf851
343f76a
8477297
7f51f70
19f39a8
8e2fc86
1480bed
9d12532
251cb94
02cc724
72bdbc8
d552b3e
aab1708
bba3c2f
d915819
b88929c
0ab02c8
03aed4a
3bf63c4
8ed76d7
d00a615
3aeafe7
02fa7e8
c53a155
845006a
1b89b55
e325d51
adfc3ab
f9a0665
73d6163
7322107
4504294
912aa9a
639ff0d
26a43c1
4b2a223
4bf1f92
65abe44
3d1a831
5179206
062b104
ccc78f1
ec858ae
157054a
b4fe2ef
fcfc684
7f155e1
0913ff3
a8d2991
a5030a7
0de2d9c
9d61bff
11ee250
6645c05
1d12e3d
49a566f
50ff472
23da55c
8b35b86
e40bbbf
a552a56
04284ad
af26a63
54b6000
69175cf
f945491
527004c
3b3a8df
b105a8a
a8111ef
c2309f0
2d53603
50394ff
4afb91f
7018049
e94545e
7bb6e34
a7824c3
0faec76
4c56f0c
a8d9fca
43dcf8e
5956dd2
3142935
b33e107
4006c6f
2c99d54
036ebd8
e99fdb7
5d9dc72
63f0c0f
ea3601a
57985ba
88ca42c
7668ccc
cb5f029
9cae831
224f485
775a2db
f26dca7
58be6f6
21ece95
83464c7
2893965
ffda69b
0082c05
e71b956
3b5490e
aeb82cd
983ecdb
d19c583
26f8422
06e60fa
58219b0
1b3f47e
09593d7
5c6eeef
91e9f76
c3fef46
93abd88
2e03c50
2c2468a
a809c1c
34c5027
d2d1a36
ae959a1
9e18cc6
b48eba3
ea35dc8
6830405
3ca69c3
da31c9b
e27253e
af68bd5
9512f05
eb2c0fb
b75ec8f
a4c20aa
2ab0f26
4f134eb
ef2595d
c2ecad3
ac65c40
edd7f0b
e4a57d7
9a9a714
dadd554
1f3badf
878f60c
6ad3545
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package org.checkerframework.checker.collectionownership.qual; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
| import org.checkerframework.framework.qual.InheritedAnnotation; | ||
| import org.checkerframework.framework.qual.PostconditionAnnotation; | ||
|
|
||
| /** | ||
| * The annotated method destructs the given resource collection fields. That is, this method calls | ||
| * all required methods on their elements. | ||
| * | ||
| * <pre><code> | ||
| * {@literal @}CollectionFieldDestructor("socketList") | ||
| * void close() { | ||
| * for (Socket s : this.socketList) { | ||
| * try { | ||
| * s.close(); | ||
| * } catch (Exception e) {} | ||
| * } | ||
| * } | ||
| * </code></pre> | ||
| * | ||
| * @checker_framework.manual #resource-leak-checker Resource Leak Checker | ||
| */ | ||
| @Documented | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.METHOD}) | ||
| @PostconditionAnnotation(qualifier = OwningCollectionWithoutObligation.class) | ||
| @InheritedAnnotation | ||
| public @interface CollectionFieldDestructor { | ||
| /** | ||
| * Returns the resource collection fields whose collection obligation the destructor fulfills. | ||
| * | ||
| * @return the resource collection fields whose collection obligation the destructor fulfills | ||
| */ | ||
| String[] value(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package org.checkerframework.checker.collectionownership.qual; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
| import org.checkerframework.framework.qual.InheritedAnnotation; | ||
|
|
||
| /** | ||
| * A method carrying this annotation creates a {@code CollectionObligation} for the receiver | ||
| * collection. | ||
| * | ||
| * <p>Consider a call to a {@code CreatesCollectionObligation}-annotated method. If the receiver is | ||
| * of type {@code @OwningCollectionWithoutObligation}, it is unrefined to {@code @OwningCollection}, | ||
| * and a CollectionObligation is created for each {@code @MustCall} method of the type variable of | ||
| * the receiver. | ||
| * | ||
| * <p>This annotation should only be used on method declarations of collections, as defined by the | ||
| * CollectionOwnershipChecker, that is, {@code java.lang.Iterable} and {@code java.util.Iterator} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the reference to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is out of date. Iterators are not owning. Thanks for catching it. |
||
| * implementations. | ||
| * | ||
| * @checker_framework.manual #resource-leak-checker Resource Leak Checker | ||
| */ | ||
| @Documented | ||
| @InheritedAnnotation | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.METHOD}) | ||
| public @interface CreatesCollectionObligation {} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package org.checkerframework.checker.collectionownership.qual; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
| import org.checkerframework.framework.qual.SubtypeOf; | ||
|
|
||
| /** | ||
| * An expression of type {@code NotOwningCollection} is a non-owning reference to a resource | ||
| * collection/array. Because it does not own the underlying collection/array, it cannot add or | ||
| * remove elements from it. | ||
| * | ||
| * @checker_framework.manual #resource-leak-checker Resource Leak Checker | ||
| */ | ||
| @Documented | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) | ||
| @SubtypeOf({}) | ||
| public @interface NotOwningCollection {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package org.checkerframework.checker.collectionownership.qual; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
| import org.checkerframework.framework.qual.SubtypeOf; | ||
|
|
||
| /** | ||
| * An expression of type {@code @OwningCollection} is a resource collection/array that definitely | ||
| * owns the underlying collection/array. It can add or remove elements from the collection/array. | ||
| * | ||
| * <p>The annotated expression (or one of its aliases) must either call the methods in the | ||
| * {@code @MustCall} type of its elements on all of its elements, or pass on the obligation to | ||
| * another expression. | ||
| * | ||
| * @checker_framework.manual #resource-leak-checker Resource Leak Checker | ||
| */ | ||
| @Documented | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) | ||
| @SubtypeOf({NotOwningCollection.class}) | ||
| public @interface OwningCollection {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package org.checkerframework.checker.collectionownership.qual; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
| import org.checkerframework.framework.qual.DefaultFor; | ||
| import org.checkerframework.framework.qual.DefaultQualifierInHierarchy; | ||
| import org.checkerframework.framework.qual.SubtypeOf; | ||
| import org.checkerframework.framework.qual.TypeUseLocation; | ||
|
|
||
| /** | ||
| * The bottom qualifier of the Collection Ownership type hierarchy. It is the default qualifier. | ||
| * | ||
| * <p>An expression of type {@code @OwningCollectionBottom} is either not a collection/array or is a | ||
| * collection/array whose elements have empty {@code @MustCall} type. | ||
| * | ||
| * @checker_framework.manual #resource-leak-checker Resource Leak Checker | ||
| */ | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) | ||
| @SubtypeOf({OwningCollectionWithoutObligation.class}) | ||
| @DefaultQualifierInHierarchy | ||
| @DefaultFor({ | ||
| TypeUseLocation.EXCEPTION_PARAMETER, | ||
| TypeUseLocation.RESOURCE_VARIABLE, | ||
| TypeUseLocation.RETURN, | ||
| TypeUseLocation.UPPER_BOUND | ||
| }) | ||
| public @interface OwningCollectionBottom {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the changes in this file belong in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. Removed suppressions from this file.