MumbleCloseable

Gernot Neppert mcnepp02 at googlemail.com
Tue Jun 25 23:31:36 PDT 2013


If we went the way with the "Hint" annotation, I don't see why we'd need
the additional AutoCloseable-derived interface at all.
"Hint" could simply reside were it belongs: in AutoCloseable!

As an alternative, one could probably scrap "Hint" altogether and use
"@SuppressWarnings" instead, with a standardized warning such as "resource".
That conveys the intent almost as clearly, I think...






2013/6/25 Brian Goetz <brian.goetz at oracle.com>

> 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-observers mailing list