Top Description Methods
org.checkerframework.framework.qual

public @Interface Covariant

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:TYPE
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target

A marker annotation, written on a class declaration, that signifies that one or more of the class's type parameters can be treated covariantly. For example, if MyClass has a single type parameter that is treated covariantly, and if B is a subtype of A, then SomeClass<B> is a subtype of SomeClass<A>.

Ordinarily, Java treats type parameters invariantly: SomeClass<B> is unrelated to (neither a subtype nor a supertype of) SomeClass<A>.

It is only safe to mark a type parameter as covariant if clients use the type parameter in a read-only way: clients read values of that type but never modify them.

This property is not checked; the @Covariant is simply trusted.

Here is an example use:

@Covariant(0)
public interface Iterator<E extends @Nullable Object> { ... }

Method Summary

Modifier and TypeMethod and Description
public int[]
value()

The zero-based indices of the type parameters that should be treated covariantly.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public int[] value()

The zero-based indices of the type parameters that should be treated covariantly.