OpenJDK: Implement JVM_CopySwapMemory - #23
Open
guillerodriguez wants to merge 1 commit into
Open
Conversation
guillerodriguez
force-pushed
the
feat/openjdk-copyswapmemory
branch
2 times, most recently
from
August 23, 2026 23:07
dbd8f3a to
650da17
Compare
OpenJDK 8u201 added JVM_CopySwapMemory (as part of the OpenJDK 8 backport of JDK-8141491), which copies memory between two regions while swapping the byte order of each element. Without it, the process crashes on the first bulk NIO transfer involving a byte-swapped buffer. The implementation uses a simple byte-reversal loop with byte-wise reads and writes, allowing unaligned source and destination addresses. The copy is overlap-safe: When the ranges overlap, copying proceeds in a direction that prevents unread source bytes from being overwritten. Signed-off-by: Guillermo Rodríguez <grodriguez@ingelabs.com>
guillerodriguez
force-pushed
the
feat/openjdk-copyswapmemory
branch
from
August 23, 2026 23:20
650da17 to
09880a9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
OpenJDK 8u201 added JVM_CopySwapMemory (as part of the OpenJDK 8 backport of JDK-8141491), which copies memory between two regions while swapping the byte order of each element. Without it, the process crashes on the first bulk NIO transfer involving a byte-swapped buffer.
The implementation is a simple byte-reversal loop: alignment-safe (element accesses go through memcpy) and overlap-safe (copying backwards when the destination might lie within the source).