MumbleCloseable
Brian Goetz
brian.goetz at oracle.com
Tue Jun 25 12:56:29 PDT 2013
First, note that propagating through combinators is a nice-to-have, not
a requirement; if statically identifying this was never possible, that
would still be OK.
That said, a JSR-308 checker could have rules for propagating through
combinators like concat(). No additional versions are needed in the
library.
On 6/25/2013 3:52 PM, Remi Forax wrote:
> On 06/25/2013 06:41 PM, Brian Goetz wrote:
>> 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) { ... }
>> }
>
> Could you provide an example that use concat() to concatenate two
> streams in the two cases ?
> I don't understand how it can works without providing 4 (may be 3)
> versions of concat (hold/doesn't hold for each parameter).
>
> Rémi
>
>>
>>
>>
>>
>> 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