@Retention(value=RUNTIME) @Target(value={METHOD,PARAMETER,FIELD}) public @interface Owning
This annotation is a declaration annotation rather than a type annotation, because it does not logically belong to any type hierarchy. Logically, it is a directive to the Resource Leak Checker that informs it whether it is necessary to check that a value's must-call obligations have been satisfied. In that way, it can be viewed as an annotation expressing an aliasing relationship: passing a object with a non-empty must-call obligation to a method with an owning parameter resolves that object's must-call obligation, because the ownership annotation expresses that the object at the call site and the parameter in the method's body are aliases, and so checking only one of the two is required.
Methods are treated as if they have this annotation by default unless their method is
annotated as NotOwning
. Parameters and fields are treated as NotOwning
by
default.
When the -AnoLightweightOwnership command-line argument is passed to the checker, this
annotation and NotOwning
are ignored.