RFR: 6539707: (fc) MappedByteBuffer.force() method throws an IOException in a very simple test [v2]
Brian Burkhalter
bpb at openjdk.java.net
Wed Feb 24 01:14:44 UTC 2021
On Sun, 21 Feb 2021 16:51:49 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Brian Burkhalter has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - 6539707: Fix whitespace error
>> - 6539707: Spec force() method of MappedByteBuffer and MappedMemorySegments to throw UncheckedIOException
>
> src/java.base/share/classes/java/nio/MappedByteBuffer.java line 293:
>
>> 291: try {
>> 292: SCOPED_MEMORY_ACCESS.force(scope(), fd, address, isSync, index, length);
>> 293: } catch (Exception unspecifiedException) {
>
> The underlying force method should be changed to declare that it throws IOException and that will avoid the need to catch "unexpectedException" here.
>
> Also I think we to need to decide if the force methods should be specified to throw UncheckedIOException rather than an "unspecified exception". The API changes will need to be coordinated with Project Panama and the MappedMemorySegments.force spec.
In commit [df506b9](https://github.com/openjdk/jdk/pull/2636/commits/df506b9b09d6545982ed946d13737d5829863932), `MappedMemoryUtils.force()` is modified to rethrow an `IOException` thrown by `MappedMemoryUtils.force0()` as an `UncheckedIOException` with the `IOException` as its cause. The specifications of `force()` in `MappedByteBuffer` and `MappedMemorySegments` are modified to specify that such an `UncheckedIOException` will be thrown if the underlying operation fails.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2636
More information about the nio-dev
mailing list