RFR: 8299684: (bf) JNI direct buffer functions with large capacity behave unexpectedly [v16]

David Holmes dholmes at openjdk.org
Thu Jan 19 07:45:36 UTC 2023


On Wed, 18 Jan 2023 17:17:44 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Remove cast in `JNI::NewDirectByteBuffer`of `long` capacity to `int`, modify the constructor in question to accept a `long` capacity, and verify in the constructor that the  capacity does not overflow `int` range, throwing IAE If it does.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8299684: Further cleanup around handling OOME (or not)

test/jdk/java/nio/jni/NewDirectByteBuffer.java line 130:

> 128:     void illegalCapacities(long capacity) {
> 129:         assertThrows(IllegalArgumentException.class, () -> {
> 130:             long addr = UNSAFE.allocateMemory(capacity);

How is `allocateMemory` going to respond to these illegal capacity requests?

If we expect `newDirectByteBuffer` to throw then can't we use a dummy buffer value as it will never be used?

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

PR: https://git.openjdk.org/jdk/pull/11873


More information about the hotspot-dev mailing list