Based on this annotation, flow oriented analysis tools can be made more precise without the need to perform
full-system analysis, as the @Owning annotation describes a contract, consisting of two sides that can be
checked independently.
The Eclipse Compiler for Java™ (version 3.37 and greater) interprets this annotation when placed on a value of
type AutoCloseable or any subtype. This annotation is interpreted specifically in these locations:
ElementType#PARAMETER):@Owning denotes that the responsibility to close a resource passed into this parameter will lie with the
receiving method, on this particular flow.
ElementType#METHOD) - as a way to refer to the method return value:@Owning denotes that responsibility to close a resource received from a call to this method will lie
with the receiving code.
ElementType#FIELD)AutoCloseable. In that case, it will be the responsibility of the class's
close() implementation to also close all resources stored in @Owning fields.
ElementType#TYPE_USE)this parameter) as owning signals that the method is responsible
for closing all contained resources. The method will be treated as a "custom close method".Responsibility to close a resource may initially arise from these situations:
AutoCloseable.AutoCloseable (or subtype) that is marked as @Owning.@Owning and returns AutoCloseable (or a subtype).
@Owning annotation is absent in this situation, the receiving method is potentially responsible.close() method of a class implementing AutoCloseable, and within each "custom close method",
each resource field annotated as @Owning must be closed.Responsibility to close a resource may be fulfilled by ensuring any of these measures on every possible path:
AutoCloseable#close() or a "custom close method".AutoCloseable (or subtype)
and is marked as @Owning.@Owning and has a declared return type
of AutoCloseable (or a subtype).@Owning.
close() method of a class implementing AutoCloseable and within a "custom close method"
closing the resource held by a field tagged as @Owning can happen either directly, or for inherited fields
by invoking super.close(), or the super version of a "custom close method".