Annotation Type EnsuresNonNull


  • @Retention(CLASS)
    @Target({METHOD,CONSTRUCTOR})
    public @interface EnsuresNonNull
    An annotation describing a nullability post-condition for an instance method. Each parameter to the annotation should be a field of the enclosing class. The method must ensure that whenever the method exits normally, the fields listed in the annotation are non-null. NullAway verifies that this property holds, and the property is used when checking call sites of the method. Here is an example:
     class Foo {
         @Nullable Object theField;
         @EnsuresNonNull("theField") // @EnsuresNonNull("this.theField") is also valid
         void foo() {
             theField = new Object();
         }
         void bar() {
             foo();
             // No error, NullAway knows theField is non-null after call to foo()
             theField.toString();
         }
     }
     
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String[] value  
    • Element Detail

      • value

        java.lang.String[] value