MumbleCloseable

Brian Goetz brian.goetz at oracle.com
Tue Jun 25 09:41:07 PDT 2013


Following along this line, some structural choices for hint annotations. 
  I think the key hint is "definitely holds", though we might also want 
"definitely does not hold".

interface MayHoldCloseableResource extends AutoCloseable {
     void close();  // no exceptions

     @interface DefinitelyHolds { }
}

...

package java.nio;
class Files {
     ...
     @MayHoldCloseableResource.DefinitelyHolds
     Stream<String> lines(Path p) { ... }
}

or...

interface MayHoldCloseableResource extends AutoCloseable {
     void close();  // no exceptions

     enum HoldHint { YES, NO }
     @interface Hint {
         HoldHint value();
     }
}

...

package java.nio;
class Files {
     ...
     @MayHoldCloseableResource.Hint(YES)
     Stream<String> lines(Path p) { ... }
}




On 6/25/2013 11:37 AM, Brian Goetz wrote:
> Actually,
>
> MayHoldCloseableResource
>
> seems not too bad.  It is a tad wordy, but relatively few people will
> have to type it, and reading it is pretty clear -- this object may hold
> a closeable resource.
>
> On 6/25/2013 11:14 AM, Brian Goetz wrote:
>>> These together provide something better than any other related
>>> schemes I know. I think that if we cam up with stunningly
>>> good names for these, the plan would be completely uncontroversial.
>>
>> MayHoldResource
>> HoldsResource
>> MayRequireClosing
>> ...


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