OfAddress setter should disallow heap segments

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • 20
    • Affects Version/s: 20
    • Component/s: core-libs
    • None

        The following test currently fails:

            @Test(expectedExceptions = IllegalArgumentException.class,
                expectedExceptionsMessageRegExp = ".*Heap segment not allowed.*")
            public void testNoHeapSets() {
                MemorySegment targetSegment = MemorySegment.allocateNative(ADDRESS.byteSize(), SegmentScope.auto());
                MemorySegment segment = MemorySegment.ofArray(new byte[]{ 0, 1, 2 });
                targetSegment.set(ADDRESS, 0, segment); // should throw
            }

        i.e. it is possible to set a heap segment's address into another memory segment. The address of a heap segment is a virtual address, so doing this is non-sensicle.

        This should be blocked.

              Assignee:
              Maurizio Cimadamore
              Reporter:
              Jorn Vernee
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: