RFR(JDK11/NIO) 8205058 throw CharacterCodingException --> Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file
huizhe.wang at oracle.com
Tue Jun 26 17:41:35 UTC 2018
On 6/26/18, 6:54 AM, Alan Bateman wrote:
> On 26/06/2018 05:50, Joe Wang wrote:
>> Hi Alan, Sherman,
>> Here's a version where we, as Sherman suggested, throw an IAE with
>> CCE as the cause. This approach reduces code duplication in SC,
>> although it complicates the impl a little bit with the added
>> parameter and the different behavior between the existing usages of
>> the methods and the new ones. The existing code paths are kept intact
>> so there's no compatibility issue for the existing code.
>> This version also did not remove the try-catch in Files as Alan
>> suggested earlier.
> This version looks much better. In StringCoding, do you really need
> throwCCE? The encode/decode methods do a replace or throw so I assume
> one flag will do. If combined with Sherman suggestion then it would be
> minimal changes to StringCoding. It would be nice to get rid of the
> IAE completely but that is for another day. In Files then you don't
> need to check if cause is null before testing its type.
Yes, combined with Sherman's suggestion eliminated the need for the new
parameter. Here's the updated webrev:
> The update tests to check for UnmappedCharacterException and
> MalformedInputException look good.
More information about the nio-dev