[foreign-memaccess] RFR: Memory access implementation rewrite - post cleanup

Jorn Vernee jvernee at openjdk.java.net
Wed Apr 15 14:43:59 UTC 2020


On Wed, 15 Apr 2020 13:46:16 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> * Fix access modes not preserved in AbstractMemorySegmentImpl.ofBuffer
> * Add check to ensure that Foreign::withSize and Foreign::asMallocSegment are called with unchecked address

Besides testing whether read-only would be preserved for round trips, I think it would be nice to also test that lack
of CLOSE and ACQUIRE are preserved. How about:

    @Test
    public void testRoundTripAccess() {
        try(MemorySegment ms = MemorySegment.allocateNative(4)) {
            MemorySegment msNoAccess = ms.withAccessModes(MemorySegment.READ); // READ is required to make BB
            MemorySegment msRoundTrip = MemorySegment.ofByteBuffer(msNoAccess.asByteBuffer());
            assertEquals(msNoAccess.accessModes(), msRoundTrip.accessModes());
        }
    }
(tested locally)

---

Otherwise looks good. Thanks for fixing!

-------------

Marked as reviewed by jvernee (Committer).

PR: https://git.openjdk.java.net/panama-foreign/pull/111


More information about the panama-dev mailing list