8000 Preserve direct buffer marks in Pointer.toBuffer by RicheyWorks · Pull Request #49 · jcuda/jcuda · GitHub
[go: up one dir, main page]

Skip to content

Preserve direct buffer marks in Pointer.toBuffer - #49

Draft
RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/preserve-direct-buffer-marks
Draft

RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/preserve-direct-buffer-marks

Conversation

@RicheyWorks
Copy link
Copy Markdown

Calling Pointer.toBuffer on a direct buffer temporarily lowers its position to zero, discarding any nonzero mark. Restoring the position does not restore the mark, so a later caller reset() throws InvalidMarkException.

Duplicate the supplied direct buffer before adjusting its position in each of the six supported typed overloads. The duplicate shares the same memory and retains the existing byte-offset calculation, while leaving the caller's position, limit and mark intact. Document this behavior and add 13 regression cases covering direct buffers, slices and a read-only byte buffer.

Validation:

  • All 13 regression cases fail against unchanged upstream and pass with this fix.
  • Maven compiled 222 main sources and all 13 test sources, then ran PointerBufferStateTest: 13 tests, 0 failures, 0 errors, 0 skipped, using the declared JUnit 4.13.1.
  • The installed JDK 22 rejects the parent's Java 7 source/target settings. For that Maven run only, the separate jcuda-parent POM installed into an isolated local cache used Java 8 source/target. No POM adjustment is included in this contribution.
  • All main Java sources also compile with javac --release 8.
  • CUDA-dependent tests were not run because the GPU was reserved for another workload. No JNI changes are included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0