refactor: extract native-call helpers into NativeCall#14
Merged
Conversation
Move the FFM-downcall conventions out of Zstd into a dedicated package-private NativeCall: - interface ZstdCall (was SizeCall) - checkReturnValue(ZstdCall) (was call) — run a size_t call, decode a ZSTD_isError code into a ZstdException - isError / errorCode / errorName - requireNative segment guard Zstd keeps its one-shot byte[] API plus copyIn/copyOut. All call sites (contexts, streams, dicts, frame, bounds) repointed. No behaviour change; these are all package-private internals. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…Call Every binding class carried its own private rethrow/sneaky to launder the checked Throwable from MethodHandle.invokeExact. Replace them with one shared NativeCall.rethrow and repoint all catch blocks. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Name BOUNDS_LAYOUT's fields (error/lowerBound/upperBound) and derive the read offsets from it with byteOffset(groupElement(...)), so the struct reads track the definition instead of hand-counted 0/8/12. Document how the struct-by-value return allocates through the arena SegmentAllocator. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Related internal refactors, all package-private — no public API / javadoc surface change.
1. Extract
NativeCallMove the FFM-downcall conventions out of
Zstd:interface ZstdCall(wasSizeCall)checkReturnValue(ZstdCall)(wascall) — run asize_tcall, decode aZSTD_isErrorcode into aZstdExceptionisError/errorCode/errorNamerequireNativesegment guardZstdkeeps its public one-shotbyte[]API +copyIn/copyOut. All call sites repointed.2. Collapse duplicated
rethrow/sneaky13 binding classes each carried their own copy of the unchecked-rethrow helper. Replaced with one shared
NativeCall.rethrow.3. Read
ZSTD_boundsvia its named layoutName
BOUNDS_LAYOUT's fields and deriveZstdBounds.query's read offsets withbyteOffset(groupElement(...))instead of hand-counted0/8/12, plus a comment on how the struct-by-value return allocates through the arenaSegmentAllocator.Test
./mvnw -pl zstd,integration-tests -am verify— 138 unit + 79 integration green, checkstyle + javadoc clean.🤖 Generated with Claude Code