Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
8259636: Check for buffer backed by shared segment kicks in in unexpe…
Browse files Browse the repository at this point in the history
…cted places

Reviewed-by: sundar, alanb, chegar
  • Loading branch information
mcimadamore committed Jan 12, 2021
1 parent 5f9cd72 commit 17b4db3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -203,7 +203,7 @@ class Direct$Type$Buffer$RW$$BO$
{
#if[rw]
super(mark, pos, lim, cap, segment);
address = db.address() + off;
address = ((Buffer)db).address + off;
#if[byte]
cleaner = null;
#end[byte]
Expand Down
10 changes: 9 additions & 1 deletion test/jdk/java/foreign/TestByteBuffer.java
Expand Up @@ -64,7 +64,6 @@
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
Expand Down Expand Up @@ -668,6 +667,15 @@ public void buffersAndArraysFromSlices(Supplier<MemorySegment> segmentSupplier)
}
}

@Test(dataProvider="segments")
public void viewsFromSharedSegment(Supplier<MemorySegment> segmentSupplier) {
try (MemorySegment segment = segmentSupplier.get().share()) {
var byteBuffer = segment.asByteBuffer();
byteBuffer.asReadOnlyBuffer();
byteBuffer.slice(0, 8);
}
}

@DataProvider(name = "segments")
public static Object[][] segments() throws Throwable {
return new Object[][] {
Expand Down

1 comment on commit 17b4db3

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.