[Fix][Engine] Fix JDK 8 NoSuchMethodError in StainTracePayload#append#10994
Open
davidzollo wants to merge 2 commits into
Open
[Fix][Engine] Fix JDK 8 NoSuchMethodError in StainTracePayload#append#10994davidzollo wants to merge 2 commits into
davidzollo wants to merge 2 commits into
Conversation
ByteBuffer.position(int) was overridden with a covariant ByteBuffer return type in JDK 9+. When code compiled on JDK 9+ runs on JDK 8, the JVM cannot find ByteBuffer.position(I)LByteBuffer; and throws NoSuchMethodError. Cast to the Buffer superclass so the call resolves to Buffer.position(I)LBuffer; which is present on JDK 8. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
|
+1 good job🚀 |
DanielLeens
reviewed
Jun 2, 2026
Contributor
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for working on this. I reviewed the latest head from scratch and checked the exact binary-payload append path that runs when stain-trace sampling records another stage hop.
What this PR solves
- User pain: on JDK 8,
StainTracePayload.append(...)can hitNoSuchMethodErrorbecause the compiled call targets the JDK 9+ covariantByteBuffer.position(int)signature instead of the JDK 8Buffer.position(int)signature. - Fix approach: cast the wrapped buffer to
Bufferbefore callingposition(int), so the call binds to the JDK 8-compatible superclass method. - One-line summary: this is a precise compatibility fix on the real payload-append hot path, and I did not find a new source-level blocker.
Runtime path I checked
sampled row trace path
-> StainTracePayload.append(...) [81-101]
-> validate payload
-> expand byte array
-> move write cursor to old payload length
-> append stage code / task ID / timestamp
-> update entry count
Review result
StainTracePayload.java:90-100is exactly the right place to fix this.- The new cast at
StainTracePayload.java:92-96is minimal and targeted: it preserves the existing binary layout while avoiding the JDK 8 linkage problem. - I did not see a reopened compatibility or payload-corruption risk from this change.
Tests / CI
- The code change is very small and the compatibility rationale is clear from the in-code comment.
- The current apache-side
Buildcheck is red, but the corresponding fork Actions run I inspected is still in progress and has not yet produced a clean final PR-specific failure diagnosis. So I am not treating that red badge as source evidence against this fix.
Conclusion: can merge after fixes
- Blocking items
- No source-level blocker from my side on the latest head.
- Please make sure the branch ends up with one valid CI result before merge, because the current public
Buildbadge is not a trustworthy final signal yet.
- Suggested non-blocking follow-up
- None from my side on this code path.
From the code-review side, the JDK 8 compatibility fix itself looks good.
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.
Purpose
Fix a JDK 8 runtime incompatibility in
StainTracePayload#append.Problem
In JDK 9+,
ByteBufferadded a covariant override ofBuffer.position(int)that returnsByteBufferinstead ofBuffer.When the project is compiled on JDK 9+ (which emits bytecode referencing
ByteBuffer.position(I)LByteBuffer;) and then run on JDK 8, the JVM cannot resolve that method descriptor and throws:The affected line is in
append():Fix
Cast to the
Buffersuperclass so the call always resolves toBuffer.position(I)LBuffer;, which exists on every JDK version:This is the standard idiom used throughout the JDK and many libraries to keep
ByteBuffercode compatible with JDK 8.Checklist
StainTracePayloadTest) pass