RFR 8180410: ByteArrayOutputStream should not throw IOExceptions

Stuart Marks stuart.marks at oracle.com
Wed Mar 21 20:23:47 UTC 2018


On 3/21/18 1:01 PM, Brian Burkhalter wrote:
> On Mar 21, 2018, at 12:34 PM, Stuart Marks <stuart.marks at oracle.com 
> <mailto:stuart.marks at oracle.com>> wrote:
>
>> Having this as an @implSpec sounds as if the implementation of this method in 
>> BAOS is *required* to call write(b, 0, b.length). It happens to do that in 
>> the current webrev, but this is not a requirement on the implementation. (At 
>> least that doesn't appear to be the intent.)
>
> Perhaps instead the verbiage just needs to be changed to, e.g.,
>
> “The implementation in this class simply invokes {@link #write(byte[],int,int) 
> write(b, 0, b.length)}.”
I don't think you want to specify this detail about the implementation.

Consider a possible future refactoring, where writeBytes() calls some internal 
method instead of calling write(b, 0, b.length). This might be done, for 
example, to leverage an intrinsic, or to avoid unnecessary bounds checks, or for 
some other reason we can't imagine at the moment.

Such a refactoring would be prohibited by an @implSpec.

s'marks



More information about the core-libs-dev mailing list