MumbleCloseable

Joseph Darcy joe.darcy at oracle.com
Wed Jun 26 19:37:37 PDT 2013


Hello,

On 6/24/2013 6:04 PM, Brian Goetz wrote:
> This note attempts to tie together the issues that have been raised 
> for streams having a resource release mechanism.  For an explanation 
> of why the initial attempt (which included the high-noise-to-signal 
> classes CloseableStream and DelegatingStream) was impractical, see 
> Paul's note here:
>

[snip]

Just to provide some additional context from the design of 
try-with-resources in JDK 7. The try-with-resources feature was intended 
to provide a robust mechanism to call a particular method at the end of 
a lexical block. The primary use case was "GCR" entities related to I/O, 
but the try-with-resources feature was never intended to be limited to 
I/O. The were ideas floating to define "AutoDisposable" to live 
alongside "AutoCloseable", but that was not deemed necessary. There was 
also some consideration given to adding AutoCloseable subtypes like 
"SilentCloseable" (throws no exceptions) and "IdempotentCloseable" 
(second and subsequent close calls are no-ops), but those were not added 
either.

Given that background, I think it is reasonable and consistent with the 
design intentions of AutoCloseable and try-with-resources to define a 
specialized AutoCloseable subtype for streams which indicates handling 
and semantics appropriate for this new class of API.

Cheers,

-Joe


More information about the lambda-libs-spec-experts mailing list