Top Description Methods
org.checkerframework.checker.mustcall.qual

public @Interface MustCallAlias

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:PARAMETER, CONSTRUCTOR, METHOD, TYPE_USE
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target

This polymorphic annotation represents an either-or must-call obligation. This annotation should always be used in pairs. On a method, it is written on some formal parameter type and on the method return type. On a constructor, it is written on some formal parameter type and on the result type. Fulfilling the must-call obligation of one is equivalent to fulfilling the must-call obligation of the other.

This annotation is useful for wrapper objects. For example, consider the declaration of java.net.Socket#getOutputStream:

@MustCall("close")
class Socket {
  @MustCallAlias OutputStream getOutputStream(@MustCallAlias Socket this) { ... }
}
Calling close() on the returned OutputStream will close the underlying socket, but the Socket may also be closed directly, which has the same effect.

Verifying @MustCallAlias annotations

Suppose that @MustCallAlias is written on the type of formal parameter p.

For a constructor:

For a method: When the -AnoResourceAliases command-line argument is passed to the checker, this annotation is treated identically to PolyMustCall.

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString