While reviewing FileChannel#map API after merging the Panama Foreign I noticed some inconsistencies between implementation and documentation:
The new method returning MemorySegment, which was added to FileChannel class couldn't be made abstract (backwards compatibility). Therefore the default implementation is just throwing UnsupportedOperationException.
In the documentation it says:
* @throws UnsupportedOperationException
* If an unsupported map mode is specified.
This statement is incomplete, because it also throws this exception when a custom FileSystem implementation returns a FileChannel implementation that does not implement that method.
For the already existing abstract method, the same statement is given, but I'd suggest to change the spec here, too, so a custom FileSystem implementation that does not support mmap could implement the abstract method also with UnsupportedOperationException. I think jrtfs does this (not checked).
The new method returning MemorySegment, which was added to FileChannel class couldn't be made abstract (backwards compatibility). Therefore the default implementation is just throwing UnsupportedOperationException.
In the documentation it says:
* @throws UnsupportedOperationException
* If an unsupported map mode is specified.
This statement is incomplete, because it also throws this exception when a custom FileSystem implementation returns a FileChannel implementation that does not implement that method.
For the already existing abstract method, the same statement is given, but I'd suggest to change the spec here, too, so a custom FileSystem implementation that does not support mmap could implement the abstract method also with UnsupportedOperationException. I think jrtfs does this (not checked).
- relates to
-
JDK-8288080 (fc) FileChannel::map for MemorySegments should state it always throws UOE
-
- Resolved
-
- links to
-
Review openjdk/jdk/8739