JDK 9 RFR of 8130679: Writer/StringWriter.write methods do not specify index out bounds

Roger Riggs Roger.Riggs at Oracle.com
Tue May 10 15:03:40 UTC 2016


Hi Pavel,

Good catch, the javadoc needs to match the code and in this case the new 
language
does not match the code.  Some cases are harder to follow because they 
delegate
to other classes for copying.

It may also be the case that since Writer.write(char[], off, len) is 
abstract, it cannot enforce the contract
consistently on all subclasses and something special will be needed for 
that javadoc.

Roger


On 5/10/2016 10:32 AM, Pavel Rappo wrote:
> Hold it right there :-)
>
> There's an open issue about BufferedWriter
>
>    https://bugs.openjdk.java.net/browse/JDK-8029804
>
> So in this case what we've added in the @throws for
> java.io.BufferedWriter#write(java.lang.String, int, int) directly contradicts
> what it states two paragraphs above, doesn't it?
>
>     * <p> If the value of the {@code len} parameter is negative then no
>     * characters are written.  This is contrary to the specification of this
>     * method in the {@linkplain java.io.Writer#write(java.lang.String,int,int)
>     * superclass}, which requires that an {@link IndexOutOfBoundsException} be
>     * thrown.
>
> That doesn't look good.
>
>> On 10 May 2016, at 14:48, Roger Riggs <Roger.Riggs at oracle.com> wrote:
>>
>> Looks good Brian,
>>
>> Thanks
>>
>>
>> On 5/10/2016 5:36 AM, Chris Hegarty wrote:
>>> On 10 May 2016, at 00:29, Brian Burkhalter <Brian.Burkhalter at oracle.com> wrote:
>>>
>>>> Hi Roger,
>>>>
>>>> So modified:
>>>>
>>>> http://cr.openjdk.java.net/~bpb/8130679/webrev.01/
>>> This looks good to me.
>>>
>>> I have to admit that I reviewed the current wording in Reader.read, but on
>>> reflection it would be better to update it to reflect this wording. But that is a
>>> separate, lower priority, issue.
>>>
>>> -Chris.
>>>
>>>> Thanks,
>>>>
>>>> Brian
>>>>
>>>> On May 9, 2016, at 2:56 PM, Roger Riggs <roger.riggs at oracle.com> wrote:
>>>>> Yes, I think that works well.
>>>>>
>>>>> On 5/9/16 5:15 PM, Brian Burkhalter wrote:
>>>>>> So do you think that this form for example:
>>>>>>
>>>>>> (common prefix)
>>>>>>      * @throws  IndexOutOfBoundsException
>>>>>>      *          If {@code off} is negative, or {@code len} is negative,
>>>>>>      *          or {@code off + len} is negative or greater than the length




More information about the core-libs-dev mailing list