Hi Roger! Thanks for the comments!
On 8/8/19 6:50 AM, Roger Riggs wrote:
Hi Ivan,
To be consistent with other checks of the index, can you use the
checkIndex(index, length) method?
The message it produces would be appropriate for both cases.
Unfortunately, checkIndex(int, int) wouldn't be appropriate here because
it only allows index < length, while we need index <= length here.
I think it makes sense to adopt the suggestion from Claes and just
delegate to substring(int,int).
While you are there can you add a space after the comma
in lines 3680 and 3691.
Yes, done.
Is there an appropriate test? There should be.
The substring() method is used across many regression tests, so we do
have sanity checking.
I didn't think it's worth it to check for specific error message.
With kind regards,
Ivan
Thanks, Roger
On 8/7/19 8:17 PM, Ivan Gerasimov wrote:
Hello!
The exception thrown by substring(int) may look confusing.
For example it produces "String index out of range: -1" when the
index is length+1.
It is proposed to make the error message more clear, similar to what
we have for substring(int, int).
BUGURL: https://bugs.openjdk.java.net/browse/JDK-8221307
WEBREV: http://cr.openjdk.java.net/~igerasim/8221307/00/webrev/
Would you please help review?
--
With kind regards,
Ivan Gerasimov