RFR: 4833719: (bf) Views of MappedByteBuffers are not MappedByteBuffers, and cannot be forced [v6]
lyndseyBeil
github.com+81080647+lyndseybeil at openjdk.java.net
Tue Mar 23 04:58:50 UTC 2021
On Thu, 18 Mar 2021 23:53:03 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Please consider this proposal to add covariant overrides to `MappedByteBuffer` for the methods `compact()`, `duplicate()`, `slice()`, and `slice(int,int)`.
>>
>> The methods in question are added as abstract specifications in `MappedByteBuffer` and their implementations in `Direct-X-Buffer.java.template`. In `MappedByteBuffer` the `isSync()` method is changed to have package access, and a final package scope method `FileDescriptor fileDescriptor()` is added to return the associated file descriptor. Specification verbiage is added to the new covariant overrides, and the specification of `force()` is enhanced slightly. (The `unmapper()` method offers an alternative way to obtain the file descriptor and sync mode without the need for package access `fileDescriptor()` and `isSync()` methods.)
>>
>> In `Direct-X-Buffer.java.template` the constructor for duplicates and slices is modified to accept parameters for the file descriptor and sync mode for byte buffers. The uses of this constructor are correspondingly modified.
>>
>> A test is added to exercise the new methods. Verifying that `force()` is actually doing anything is not verified by this test but was checked manually. The change passes all other existing tests in tiers 1-3.
>>
>> Other methods for which it might be worth adding covariant overrides are the `get()` and `put()` methods which return a buffer, and, less interesting, the `put$Type$()` methods.
>
> Brian Burkhalter has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
>
> - Merge
> - 4833719: corrections pursuant to JDK-8263742
> - 4833719: Corrected faux pas in correcting faux pas
> - 4833719: Corrected faux pas in the slice(int,int) spec
> - 4833719: Remove @apiNotes and "A similar consideration"
> - 4833719: (bf) Views of MappedByteBuffers are not MappedByteBuffers, and cannot be forced
test/jdk/java/nio/MappedByteBuffer/ForceViews.java line 48:
> 46: public class ForceViews {
> 47:
> 48: static record Segment(int position, int length) {}
I detect that this code is problematic. According to the [Bad practice (BAD_PRACTICE)](https://spotbugs.readthedocs.io/en/stable/bugDescriptions.html#bad-practice-bad-practice), [Nm: Method names should start with a lower case letter (NM_METHOD_NAMING_CONVENTION)](https://spotbugs.readthedocs.io/en/stable/bugDescriptions.html#nm-method-names-should-start-with-a-lower-case-letter-nm-method-naming-convention).
Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2902
More information about the nio-dev
mailing list