Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8299862

OfAddress setter should disallow heap segments

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 20
    • 20
    • 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.

              mcimadamore Maurizio Cimadamore
              jvernee Jorn Vernee
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: