hg: lambda/lambda/jdk: Add BufferedReader.lines

David Holmes david.holmes at oracle.com
Sun Nov 11 15:45:42 PST 2012


On 12/11/2012 9:17 AM, Remi Forax wrote:
> On 11/12/2012 12:11 AM, Brian Goetz wrote:
>>> Brian,
>>> UncheckedIOException already exists, it's IOError.
>>
>> That exists, but is something different.
>>
>> IOError implements Error, which is intended to indicate an error
>> situation from which the VM cannot recover.  It was added to support
>> Console, for which using Error is arguably OK.  But here, an
>> IOException is clearly NOT an Error.
>>
>> Our choices where creating this class or wrapping it in an ordinary
>> RuntimeException.  Because we anticipated other cases with IO-backed
>> streams, we thought we'd get additional mileage out of this class.
>
> by example, java.nio.file.Files.newDirectoryStream uses IOError exactly
> for that.

It does? The only use of IOError I can see in java.nio.file.* is in the 
Path interface. newDirectoryStream throws IOException.

> I agree that a runtime exception is better than an Error, but given that
> some classes of the JDK already uses IOError exactly for the same
> purpose, I don't think it's a good idea to have two classes for the very
> same thing.

Error subclasses should be reserved for unrecoverable errors. Even if 
this is misused somewhere we should not perpetuate the misuse.

David

> Rémi
>
>


More information about the lambda-dev mailing list