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
Alan Bateman
Alan.Bateman at oracle.com
Tue Jun 26 13:54:50 UTC 2018
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.
>
> http://cr.openjdk.java.net/~joehw/jdk11/8205058/webrev02/
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.
The update tests to check for UnmappedCharacterException and
MalformedInputException look good.
-Alan
More information about the nio-dev
mailing list