Package com.facebook.infer.annotation
Annotation Type Functional
-
@Target(METHOD) @Retention(CLASS) public @interface Functional
Annotation for methods that always return the same value. The annotation is inherited by overrides of methods.This annotation is used to suppress benign race warnings on fields assigned to methods annotated with @Functional in the thread-safety analysis. For example:
T mField; @Functional T someMethod(); public void getField() { if (mField == null) { mField = someMethod(); } return mField; }
Normally, we'd report that the access to mField is unsafe, but we won't report here because of the @Functional annotation.
If the return value of the annotated function is a double or long, the annotation will be ignored because writes to doubles/longs are not guaranteed to be atomic. That is, if type T was `long` in the example above, the write-write race on mField would no longer be benign.