8259636: Check for buffer backed by shared segment kicks in in unexpected places
Reviewed-by: sundar, alanb, chegar
This commit is contained in:
parent
5f9cd72c54
commit
17b4db31cb
src/java.base/share/classes/java/nio
test/jdk/java/foreign
@ -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]
|
||||
|
@ -64,7 +64,6 @@ import java.nio.file.Path;
|
||||
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;
|
||||
@ -668,6 +667,15 @@ public class TestByteBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@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[][] {
|
||||
|
Loading…
x
Reference in New Issue
Block a user