Annotation Interface EnsuresInitialized


A method postcondition annotation that guarantees that the given Java expressions are Initialized after the method terminates successfully.

This annotation is useful when a method initializes a field of an object that is currently UnderInitialization (or UnknownInitialization). It tells the Initialization Checker that the field has been assigned a value.

If the receiver is already fully Initialized, this annotation provides no new information and is trivially true. If you also want to guarantee that a reference field is not null (for the Nullness Checker), use EnsuresNonNull instead, which implies initialization but also provides a nullness guarantee.

Note: This is an Initialization Checker postcondition, distinct from EnsuresInitializedFields which is used by the standalone Initialized Fields Checker.

See the Checker Framework Manual:
Initialization Checker
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    A wrapper annotation that makes the EnsuresInitialized annotation repeatable.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The Java expressions that are initialized upon successful method termination.
  • Element Details

    • value

      String[] value
      The Java expressions that are initialized upon successful method termination.
      Returns:
      the Java expressions that are initialized
      See the Checker Framework Manual:
      Syntax of Java expressions