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

Brian Burkhalter bpb at openjdk.org
Wed Jan 18 16:58:54 UTC 2023


On Wed, 18 Jan 2023 09:07:06 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8299684: Clean up memory deallocation
>
> test/jdk/java/nio/jni/NewDirectByteBuffer.java line 106:
> 
>> 104:         (long)Integer.MAX_VALUE - 1, (long)Integer.MAX_VALUE})
>> 105:     void legalCapacities(long capacity) {
>> 106:         long addr = UNSAFE.allocateMemory(capacity);
> 
> I think David was asking for the test to continue when malloc fails. Now that the test is changed to use Unsafe.allocateMemory it means it has to catch OOME.

Added catch of OOME in f9350695c3a6f90e3acdf2176d78c06406e49387.

> test/jdk/java/nio/jni/libNewDirectByteBuffer.c line 49:
> 
>> 47:     (JNIEnv *env, jclass cls, jobject buf)
>> 48: {
>> 49:     return (jlong)(*env)->GetDirectBufferAddress(env, buf);
> 
> The cast to jlong should be okay for 64-bit. For 32-bit then it will likely need a double cast, as in ((jlong)(int)( .. )) but maybe okay for now as you've restricted the test to 64-bit.

Leaving it as-is for now.

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

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


More information about the nio-dev mailing list