WIP: Fix #3316: javalib FileChannel APPEND relative writes now match JVM #3323
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #3316
The Java 8 documentation for
SeekableByteChannel$position(pos)
says:However, the JVM implementation allows it and APPEND relative writes happen at the expected place: End Of File.
As of this PR, Scala Native implements the same proscribed but not prohibited behavior.
The design center for this PR was correctness. There is no benchmark data to show it, but
both the simple and APPEND channel
write(ByteBuffer)
paths should be quickerand more efficient since a number of unnecessary file movement (lseek) calls were
eliminated.
This PR also adds some improved error reporting on not-Windows and a more
direct way, and hopefully better, way of determining file size on not-Windows.
Note:
The JVM documentation states that FileChannels are thread-safe. This implementation, and probably most other,
javalib classes outside of
java.util.concurrent
are not.~~ editorial opinion about having more than one thread using a FileChannel redacted ~~
Multiple threads on the same FileChannel may have undesired results.