RFR: 8299684: (bf) JNI direct buffer functions with large capacity behave unexpectedly [v5]
Brian Burkhalter
bpb at openjdk.org
Wed Jan 11 17:27:29 UTC 2023
On Tue, 10 Jan 2023 05:56:16 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8299684: Changes addressing reviewer comments
>
> src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template line 197:
>
>> 195: throw new IllegalArgumentException
>> 196: ("JNI NewDirectByteBuffer passed capacity < 0: ("
>> 197: + capacity + " < 0)");
>
> You don't need to repeat the `< 0` part.
I was matching `Buffer::createCapacityException` but I agree with you. Remove in 82d9e6f1f6782b180943d1136881d58dd2852e58.
> src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template line 201:
>
>> 199: throw new IllegalArgumentException
>> 200: ("JNI NewDirectByteBuffer passed capacity > Integer.MAX_VALUE: ("
>> 201: + capacity + " > Integer.MAX_VALUE)");
>
> You don't need to repeat the `> Integer.MAX_VALUE` part.
Removed in 82d9e6f1f6782b180943d1136881d58dd2852e58.
> test/jdk/java/nio/jni/NewDirectByteBuffer.java line 73:
>
>> 71: public static void main(String[] args) {
>> 72: System.out.println("--- Legal Capacities ---");
>> 73: for (long cap : LEGAL_CAPACITIES) {
>
> I would still expect this to throw OOME for the very large values, so the OOME needs to be caught so that the test continues.
Fixed in 82d9e6f1f6782b180943d1136881d58dd2852e58.
-------------
PR: https://git.openjdk.org/jdk/pull/11873
More information about the nio-dev
mailing list