RFR: 8374308: ImageBufferCache does not work as intended [v2]

David Beaumont duke at openjdk.org
Tue Jan 6 10:32:36 UTC 2026


On Mon, 5 Jan 2026 19:14:12 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java line 392:
>> 
>>> 390:     private static ByteBuffer allocateBuffer(long size) {
>>> 391:         if (size < 0 || Integer.MAX_VALUE < size) {
>>> 392:             throw new IndexOutOfBoundsException("size");
>> 
>> I don't think it can happen but I assume IAE would be more appropriate here as size is not an index.
>
> Only needs to check for the `Integer.MAX_VALUE` in any case, as `ByteBuffer::allocateDirect` throws on `size < 0`. It also uses IAE

Fair points. This is just moved code, but IOOBE is clearly not the right choice here.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29043#discussion_r2664444964


More information about the core-libs-dev mailing list