-
Notifications
You must be signed in to change notification settings - Fork 381
Extend RLC to collections of resources #7166
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
f9e3c8a
5bf6243
2d903bf
457577d
0be8bf8
0355af2
384fba1
34283fd
02b6d94
98c831b
3025ad3
395653b
a11f29a
17e413d
987f30c
0ab52aa
9a74bf6
4111e30
4337abf
8a25348
f5bac6c
161b0d9
171c64a
66361fd
dc0e806
026c94b
c732cee
81dd857
fea139b
e5e29da
8e49c89
7419cfa
8fbd9ff
3819423
794a2bf
95dc4f8
1c3ad70
ecf6bc6
c1232cb
3f75eca
23b66c0
8ae0796
779b39c
9fe30ef
326b418
f7c8de9
61c79ae
0e007b1
0da4598
7e503e9
af5fe4b
95f2170
5d79525
331931e
123f26d
d9d7feb
ee95caa
ee0ce6d
12ae8fc
b2505b7
ce34a10
73af398
75f3cbf
6134f55
fdf9b0a
0ae2cf5
dcde6c3
febc5cb
e19a61c
2468321
73b3985
2b6456c
21f3503
efa1d38
bf14a97
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
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 | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -61,6 +61,8 @@ | |||||||||||||||||||||||||||||||||||||||||
| import java.util.NoSuchElementException; | ||||||||||||||||||||||||||||||||||||||||||
| import java.util.Objects; | ||||||||||||||||||||||||||||||||||||||||||
| import org.checkerframework.afu.annotator.find.CaseUtils; | ||||||||||||||||||||||||||||||||||||||||||
| import org.checkerframework.checker.collectionownership.qual.NotOwningCollection; | ||||||||||||||||||||||||||||||||||||||||||
| import org.checkerframework.checker.collectionownership.qual.PolyOwningCollection; | ||||||||||||||||||||||||||||||||||||||||||
| import org.plumelib.util.ArraysPlume; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** A path through the AST. */ | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -295,7 +297,7 @@ public static Comparator<ASTPath> getComparator() { | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // TODO: replace w/ skip list? | ||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||
| public Iterator<ASTEntry> iterator() { | ||||||||||||||||||||||||||||||||||||||||||
| public @PolyOwningCollection Iterator<ASTEntry> iterator(@PolyOwningCollection ASTPath this) { | ||||||||||||||||||||||||||||||||||||||||||
| ImmutableStack<ASTEntry> s = this; | ||||||||||||||||||||||||||||||||||||||||||
| int n = size(); | ||||||||||||||||||||||||||||||||||||||||||
| ASTEntry[] a = new ASTEntry[n]; | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1460,18 +1462,33 @@ private static <T, S extends ImmutableStack<T>> S extend(T el, S s0) { | |||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public boolean isEmpty() { | ||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * Returns true if the stack is empty. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @return true if the stack is empty | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public boolean isEmpty(@NotOwningCollection ImmutableStack<E> this) { | ||||||||||||||||||||||||||||||||||||||||||
| return size == 0; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public E peek() { | ||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * Returns the top element of the stack, without modifying the stack. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @return the top element of the stack | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public E peek(@NotOwningCollection ImmutableStack<E> this) { | ||||||||||||||||||||||||||||||||||||||||||
| if (isEmpty()) { | ||||||||||||||||||||||||||||||||||||||||||
| throw new IllegalStateException("peek() on empty stack"); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| return elem; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public ImmutableStack<E> pop() { | ||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * Returns all of the stack except the top element. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @return all of the stack except the top element | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public ImmutableStack<E> pop(@NotOwningCollection ImmutableStack<E> this) { | ||||||||||||||||||||||||||||||||||||||||||
| if (isEmpty()) { | ||||||||||||||||||||||||||||||||||||||||||
| throw new IllegalStateException("pop() on empty stack"); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1482,11 +1499,21 @@ public ImmutableStack<E> push(E elem) { | |||||||||||||||||||||||||||||||||||||||||
| return extend(elem, this); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public int size() { | ||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * Returns the size: the number of elements in the stack. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @return the size of this stack | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public int size(@NotOwningCollection ImmutableStack<E> this) { | ||||||||||||||||||||||||||||||||||||||||||
| return size; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** Return the index-th element of this stack. */ | ||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * Returns the index-th element of this stack. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @param index which element to return | ||||||||||||||||||||||||||||||||||||||||||
| * @return the index-th element of this stack | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public E get(int index) { | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
1511
to
1517
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. 🧹 Nitpick (assertive) Consider annotating push and get for completeness. To keep the API surface consistent, annotate push/get receivers as @NotOwningCollection too. - public ImmutableStack<E> push(E elem) {
+ public ImmutableStack<E> push(@NotOwningCollection ImmutableStack<E> this, E elem) {
return extend(elem, this);
}
@@
- public E get(int index) {
+ public E get(@NotOwningCollection ImmutableStack<E> this, int index) {
int n = size();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| int n = size(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,17 +4,27 @@ | |||||||||||||||||||||
| import java.util.Collection; | ||||||||||||||||||||||
| import java.util.Iterator; | ||||||||||||||||||||||
| import java.util.LinkedHashMap; | ||||||||||||||||||||||
| import java.util.Map; | ||||||||||||||||||||||
| import org.checkerframework.checker.collectionownership.qual.OwningCollection; | ||||||||||||||||||||||
| import org.checkerframework.checker.collectionownership.qual.PolyOwningCollection; | ||||||||||||||||||||||
| import org.checkerframework.checker.mustcall.qual.NotOwning; | ||||||||||||||||||||||
| import org.checkerframework.checker.mustcall.qual.Owning; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * A simple implementation of {@link KeyedSet} backed by an insertion-order {@link | ||||||||||||||||||||||
| * java.util.LinkedHashMap} and its {@link java.util.LinkedHashMap#values() value collection}. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @param <K> the type of keys | ||||||||||||||||||||||
| * @param <V> the type of values | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| public class LinkedHashKeyedSet<K, V> extends AbstractSet<V> implements KeyedSet<K, V> { | ||||||||||||||||||||||
| /** Produces a key for a value. */ | ||||||||||||||||||||||
| private final Keyer<? extends K, ? super V> keyer; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| private final Map<K, V> theMap = new LinkedHashMap<>(); | ||||||||||||||||||||||
| /** The map that backs this set. */ | ||||||||||||||||||||||
| // Declared as LinkedHashMap because some implementations of Map prohibit null keys. | ||||||||||||||||||||||
| private final LinkedHashMap<K, V> theMap = new LinkedHashMap<>(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
Comment on lines
23
to
26
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. 🧹 Nitpick (assertive) Prefer interface type for the field to reduce coupling Declaring -import java.util.LinkedHashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
@@
- /** The map that backs this set. */
- // Declared as LinkedHashMap because some implementations of Map prohibit null keys.
- private final LinkedHashMap<K, V> theMap = new LinkedHashMap<>();
+ /** The map that backs this set (insertion-ordered). */
+ private final Map<K, V> theMap = new LinkedHashMap<>();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| /** The values in the set. Implemented as a view into the map. */ | ||||||||||||||||||||||
| final Collection<V> theValues = theMap.values(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
|
|
@@ -44,7 +54,7 @@ public boolean hasNext() { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Override | ||||||||||||||||||||||
| public V next() { | ||||||||||||||||||||||
| public @NotOwning V next() { | ||||||||||||||||||||||
| return itr.next(); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -57,7 +67,7 @@ public void remove() { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Override | ||||||||||||||||||||||
| public Iterator<V> iterator() { | ||||||||||||||||||||||
| public Iterator<V> iterator(@PolyOwningCollection LinkedHashKeyedSet<K, V> this) { | ||||||||||||||||||||||
| return new KeyedSetIterator(); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -71,7 +81,15 @@ public <T> T[] toArray(T[] a) { | |||||||||||||||||||||
| return theValues.toArray(a); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| private boolean checkAdd(int behavior, V old) { | ||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Prepares for adding an element to this. Removes the given element if {@code behavior} is | ||||||||||||||||||||||
| * REPLACE. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @param behavior what action this method should take | ||||||||||||||||||||||
| * @param old the element to be removed, if {@code behavior} is REPLACE | ||||||||||||||||||||||
| * @return true if an element was removed | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| private boolean checkAdd(@OwningCollection LinkedHashKeyedSet<K, V> this, int behavior, V old) { | ||||||||||||||||||||||
| switch (behavior) { | ||||||||||||||||||||||
| case REPLACE: | ||||||||||||||||||||||
| remove(old); | ||||||||||||||||||||||
|
|
@@ -90,7 +108,11 @@ private static boolean eq(Object x, Object y) { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Override | ||||||||||||||||||||||
| public V add(V o, int conflictBehavior, int equalBehavior) { | ||||||||||||||||||||||
| public V add( | ||||||||||||||||||||||
| @OwningCollection LinkedHashKeyedSet<K, V> this, | ||||||||||||||||||||||
| V o, | ||||||||||||||||||||||
| int conflictBehavior, | ||||||||||||||||||||||
| int equalBehavior) { | ||||||||||||||||||||||
| K key = keyer.getKeyFor(o); | ||||||||||||||||||||||
| V old = theMap.get(key); | ||||||||||||||||||||||
| if (old == null | ||||||||||||||||||||||
|
|
@@ -100,12 +122,12 @@ public V add(V o, int conflictBehavior, int equalBehavior) { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Override | ||||||||||||||||||||||
| public boolean add(V o) { | ||||||||||||||||||||||
| public boolean add(@Owning V o) { | ||||||||||||||||||||||
| return add(o, THROW_EXCEPTION, IGNORE) == null; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Override | ||||||||||||||||||||||
| public boolean remove(Object o) { | ||||||||||||||||||||||
| public boolean remove(@OwningCollection LinkedHashKeyedSet<K, V> this, Object o) { | ||||||||||||||||||||||
| return theValues.remove(o); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| 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(); | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+33
to
+39
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. 🧹 Nitpick (assertive) Mark expressions as @JavaExpression for better tooling Annotate value() so IDE tooling and the framework parse field references reliably. Apply: +import org.checkerframework.framework.qual.JavaExpression;
@@
- String[] value();
+ @JavaExpression String[] value();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| 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; | ||
skehrli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * 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} | ||
| * implementations. | ||
| * | ||
| * @checker_framework.manual #resource-leak-checker Resource Leak Checker | ||
| */ | ||
| @Documented | ||
| @InheritedAnnotation | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.METHOD}) | ||
| public @interface CreatesCollectionObligation {} | ||
skehrli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 {} | ||
skehrli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.