Skip to content

Commit 3272c84

Browse files
authored
Add annotations to Enums
1 parent 4bec906 commit 3272c84

File tree

1 file changed

+7
-3
lines changed
  • src/java.base/share/classes/java/lang

1 file changed

+7
-3
lines changed

src/java.base/share/classes/java/lang/Enum.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@
2727

2828
import org.checkerframework.checker.index.qual.NonNegative;
2929
import org.checkerframework.checker.initialization.qual.UnknownInitialization;
30+
import org.checkerframework.checker.nullness.qual.UnknownKeyFor;
3031
import org.checkerframework.checker.lock.qual.GuardSatisfied;
3132
import org.checkerframework.checker.lock.qual.GuardedByUnknown;
3233
import org.checkerframework.checker.nullness.qual.Nullable;
34+
import org.checkerframework.checker.tainting.qual.Tainted;
3335
import org.checkerframework.common.value.qual.PolyValue;
3436
import org.checkerframework.dataflow.qual.Pure;
3537
import org.checkerframework.dataflow.qual.SideEffectFree;
3638
import org.checkerframework.framework.qual.AnnotatedFor;
39+
import org.checkerframework.framework.qual.Covariant;
3740

3841
import java.io.IOException;
3942
import java.io.InvalidObjectException;
@@ -80,7 +83,8 @@
8083
* @jls 8.9.3 Enum Members
8184
* @since 1.5
8285
*/
83-
@AnnotatedFor({"lock", "nullness", "index", "value"})
86+
@AnnotatedFor({"lock", "nullness", "index", "value", "tainting"})
87+
@Covariant(0)
8488
@SuppressWarnings("serial") // No serialVersionUID needed due to
8589
// special-casing of enum classes.
8690
public abstract class Enum<E extends Enum<E>>
@@ -208,7 +212,7 @@ protected final Object clone(@GuardSatisfied Enum<E> this) throws CloneNotSuppor
208212
* method is the order in which the constants are declared.
209213
*/
210214
@SuppressWarnings({"rawtypes"})
211-
public final int compareTo(E o) {
215+
public final int compareTo(@UnknownKeyFor @Tainted E o) {
212216
Enum<?> other = (Enum<?>)o;
213217
Enum<E> self = this;
214218
if (self.getClass() != other.getClass() && // optimization
@@ -230,7 +234,7 @@ public final int compareTo(E o) {
230234
* enum type
231235
*/
232236
@SuppressWarnings("unchecked")
233-
public final Class<E> getDeclaringClass() {
237+
public final Class<@Tainted E> getDeclaringClass() {
234238
Class<?> clazz = getClass();
235239
Class<?> zuper = clazz.getSuperclass();
236240
return (zuper == Enum.class) ? (Class<E>)clazz : (Class<E>)zuper;

0 commit comments

Comments
 (0)