Re: 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

2018-06-27 Thread Joe Wang
Thanks all! Glad to be able to get this done right before the deadline :-) -Joe On 6/27/18, 12:44 AM, Alan Bateman wrote: On 26/06/2018 20:49, Joe Wang wrote: : Removed the null check. The internal impl and test guarantees it's not null indeed:

Re: 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

2018-06-27 Thread Alan Bateman
On 26/06/2018 20:49, Joe Wang wrote: : Removed the null check. The internal impl and test guarantees it's not null indeed: http://cr.openjdk.java.net/~joehw/jdk11/8205058/webrev04/ Looks good. -Alan

Re: 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

2018-06-26 Thread Xueming Shen
+1 On 6/26/18, 12:49 PM, Joe Wang wrote: On 6/26/18, 11:57 AM, Alan Bateman wrote: On 26/06/2018 18:41, Joe Wang wrote: : Yes, combined with Sherman's suggestion eliminated the need for the new parameter. Here's the updated webrev:

Re: 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

2018-06-26 Thread Joe Wang
On 6/26/18, 11:57 AM, Alan Bateman wrote: On 26/06/2018 18:41, Joe Wang wrote: : Yes, combined with Sherman's suggestion eliminated the need for the new parameter. Here's the updated webrev: http://cr.openjdk.java.net/~joehw/jdk11/8205058/webrev03/ This looks good. Just a minor nit

Re: 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

2018-06-26 Thread Joe Wang
Thanks Lance! Indeed it has been changed to CCE. I'm still familiarizing myself with IntelliJ. Opened it in NetBeans, it clearly indicates "missing @throws tag for " CCE, but I don't see anything like that in IntelliJ. Updated webrev: http://cr.openjdk.java.net/~joehw/jdk11/8205058/webrev03/

Re: 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

2018-06-26 Thread Alan Bateman
On 26/06/2018 18:41, Joe Wang wrote: : Yes, combined with Sherman's suggestion eliminated the need for the new parameter. Here's the updated webrev: http://cr.openjdk.java.net/~joehw/jdk11/8205058/webrev03/ This looks good. Just a minor nit but newStringNoRepl and getBytesNoReply don't

Re: 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

2018-06-26 Thread Lance Andersen
Hi Joe, Should src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java — /** * Constructs a new {@code String} by decoding the specified subarray of * bytes using the specified {@linkplain java.nio.charset.Charset charset}. * * The caller of this method

Re: 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

2018-06-26 Thread Joe Wang
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

Re: 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

2018-06-26 Thread Joe Wang
Hi Sherman, Combining the msg and cause is a great idea! That allowed us to satisfy the existing code without changes/additional parameter and also the new method for a CCE. I also moved the iae-catch into StringCoding, that makes Files clean of such things. Here's an updated webrev with

Re: 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

2018-06-26 Thread Alan Bateman
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

Re: 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

2018-06-25 Thread Xueming Shen
Hi Joe, I would suggest always embed a malformed exception into the iae as showed below, then the extra flag is no longer needed. private static void throwMalformed(int off, int nb) { String msg = "malformed input off : " + off + ", length : " + nb; throw new

Re: 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

2018-06-25 Thread Joe Wang
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

Re: 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

2018-06-25 Thread Joe Wang
Hi Alan, The test testMalformedRead and testMalformedWrite now expect an UnmappableCharacterException instead of IOE: webrevs: http://cr.openjdk.java.net/~joehw/jdk11/8205058/webrev01/ Thanks, Joe On 6/25/18, 9:48 AM, Joe Wang wrote: On 6/24/18, 12:11 PM, Alan Bateman wrote: On

Re: 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

2018-06-25 Thread Joe Wang
On 6/24/18, 12:11 PM, Alan Bateman wrote: On 20/06/2018 04:32, Joe Wang wrote: Thanks Alan. I created 8205058 to capture your suggestions. Please see below for more details. Changed the internal APIs to throw CCE instead. In the same way as the previous changeset for 8201276, these

Re: 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

2018-06-24 Thread Alan Bateman
On 20/06/2018 04:32, Joe Wang wrote: Thanks Alan.  I created 8205058 to capture your suggestions. Please see below for more details. Changed the internal APIs to throw CCE instead. In the same way as the previous changeset for 8201276, these methods are made specific for the use cases

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

2018-06-19 Thread Joe Wang
Thanks Alan. I created 8205058 to capture your suggestions. Please see below for more details. On 6/14/18, 4:30 AM, Alan Bateman wrote: On 12/06/2018 17:52, Joe Wang wrote: Hi all, It's been a while since the 1st round of reviews. Thank you all for the valuable comments and suggestions!

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-06-14 Thread Alan Bateman
On 12/06/2018 17:52, Joe Wang wrote: Hi all, It's been a while since the 1st round of reviews. Thank you all for the valuable comments and suggestions!  Note that Roger's last response went to nio-dev, but not core-libs-dev, I've therefore attached it below. CSR [2]: the CSR is now

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-06-13 Thread Joe Wang
Thanks Roger! I pushed the changeset after s/unmappble/unmappable, it found three of them :-) Best, Joe On 6/12/18, 10:37 AM, Roger Riggs wrote: Hi Joe, Looks good to me. Typo: StringCoding.java:1026 "unmappble" (no new webrev needed) Regards, Roger On 6/12/2018 12:52 PM, Joe Wang

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-06-12 Thread Roger Riggs
Hi Joe, Looks good to me. Typo: StringCoding.java:1026 "unmappble"  (no new webrev needed) Regards, Roger On 6/12/2018 12:52 PM, Joe Wang wrote: Hi all, It's been a while since the 1st round of reviews. Thank you all for the valuable comments and suggestions!  Note that Roger's last

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-06-12 Thread Joe Wang
Hi all, It's been a while since the 1st round of reviews. Thank you all for the valuable comments and suggestions! Note that Roger's last response went to nio-dev, but not core-libs-dev, I've therefore attached it below. CSR [2]: the CSR is now approved. Note the write method has been

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-04-30 Thread Joe Wang
Hi Hamlin, Thanks for reviewing the test! Fixed now, by calling deleteOnExit. Indeed, I didn't realize I got a few empty tmp files :-) Best, Joe On 4/28/2018 12:35 AM, Hamlin Li wrote: Hi Joe, just a minor comment about the test in ReadWriteString.java. For both testMalformedWrite and

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-04-28 Thread Hamlin Li
Hi Joe, just a minor comment about the test in ReadWriteString.java. For both testMalformedWrite and testMalformedRead, temp files are not deleted, as Files.deleteIfExists(path); is skipped by the expected IOException. File.deleteOnExit​() may help. Thank you -Hamlin On 27/04/2018 12:50

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-04-27 Thread Joe Wang
On 4/27/2018 12:50 PM, fo...@univ-mlv.fr wrote: - Mail original - De: "Joe Wang" À: "Remi Forax" , "Alan Bateman" Cc: "nio-dev" , "core-libs-dev" Envoyé:

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-04-27 Thread forax
- Mail original - > De: "Joe Wang" > À: "Remi Forax" , "Alan Bateman" > Cc: "nio-dev" , "core-libs-dev" > > Envoyé: Vendredi 27 Avril 2018 21:21:01 > Objet: Re:

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-04-27 Thread Joe Wang
Hi Rémi, Alan, I'm not sure we'd want to replace system dependent line separators with '\n'. There are cases as you described where the replacement makes sense. However,  there are other cases too. For example, the purpose is to read, edit a text file and then write it back. If this is on

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-04-27 Thread Joe Wang
On 4/27/2018 4:13 AM, Alan Bateman wrote: On 27/04/2018 05:50, Joe Wang wrote: Hi, We're looking into adding methods to Files to read a file into a String/write a String to a file. Below is the current proposal. Please review. JBS: https://bugs.openjdk.java.net/browse/JDK-8201276

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-04-27 Thread forax
Hi Alan, People do not read the documentation. So adding something in the documentation about when a method should be used or not is never a solution. Here the user want a String and provides a charset so you have no way but to decode the content to substitute the line separator. cheers, Rémi

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-04-27 Thread Alan Bateman
On 27/04/2018 12:29, Remi Forax wrote: I think that having a readString that includes OS dependent line separators is a mistake, Java does a great job to try to shield the developer from the kind of things that makes programs behave differently on different platforms. readString should

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-04-27 Thread Remi Forax
I think that having a readString that includes OS dependent line separators is a mistake, Java does a great job to try to shield the developer from the kind of things that makes programs behave differently on different platforms. readString should subtitute (\r)?\n to \n otherwise either people

Re: RFR (JDK11/NIO) 8201276: (fs) Add methods to Files for reading/writing a string from/to a file

2018-04-27 Thread Alan Bateman
On 27/04/2018 05:50, Joe Wang wrote: Hi, We're looking into adding methods to Files to read a file into a String/write a String to a file. Below is the current proposal. Please review. JBS: https://bugs.openjdk.java.net/browse/JDK-8201276 webrev: