On 07/10/2013 11:30 PM, Henry Jen wrote:

A new interface, java.util.MayHoldCloseableResource, indicates an
implementation may or may not hold a resource need to be closed.

Why doesn't close() throw Exception?

Annotation {@link HoldsResource} may be used to guide users/static
analysis tools that a MHCR instance that definitely hold a Closeable
resource.

All this looks a bit odd to me. I suppose the idea is that you don't want to give up the last reference to a closeable resource without calling close()—and not leak references which out-live the call to close(). This is definitely not a property of the type of the resource, so I don't see why the MayHoldCloseableResource interface is needed (or can confer relevant information). The HoldsResource annotation could be useful, but based on the current documentation, it's not clear if it is actually intended to express the data flow property.

--
Florian Weimer / Red Hat Product Security Team

Reply via email to