On Wed, 5 May 2021 11:00:21 GMT, Rémi Forax
<[email protected]> wrote:
>> src/java.base/share/classes/java/io/FileInputStream.java line 284:
>>
>>> 282: long size = length - position;
>>> 283: if (size > (long)Integer.MAX_VALUE)
>>> 284: throw new OutOfMemoryError("Required array size too
>>> large");
>>
>> What do you think of adding "length, position, and size" to the exception
>> message?
>
> We usually don't do that for OutOfMemoryError because concatenation implies
> allocation
Well, here `OutOfMemory` is more like "I can't read all the data since the
array won't fit".
It would definitely help to have actual file size there, especially in case
filesystem returns weird values (e.g. negative file length).
This branch will almost never be taken, and even if taken, it won't be "low
memory" condition. So the allocation does not hurt, however, it would simplify
the analysis should the case trigger.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3845