Hi Johannes,

> On May 14, 2020, at 7:24 AM, Johannes Kuhn <[email protected]> wrote:
> 
> Found a small mismatch between the specification of 
> DataInputStream.readFully(byte[] b, int off, int len) and its implementation.
> 
> In particular, it doesn't throw an IndexOutOfBoundsException if offset is 
> negative and len is 0.

It looks like you are correct. Objects.checkFromIndexSize() should ideally be 
used here [1].

> Reproducer below.
> 
> I suggest changing the specification of this method to allow that behavior.

The usual practice for longstanding API discrepancies is to change the spec to 
match the behavior.

> This change should also affect DataInput, where care has to be taken that 
> both behaviors are legal.

I’ll file an issue.

Thanks,

Brian

[1] 
https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/util/Objects.html#checkFromIndexSize(int,int,int)

Reply via email to