mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
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
2 changed files with 10 additions and 2 deletions
|
@ -203,7 +203,7 @@ class Direct$Type$Buffer$RW$$BO$
|
||||||
{
|
{
|
||||||
#if[rw]
|
#if[rw]
|
||||||
super(mark, pos, lim, cap, segment);
|
super(mark, pos, lim, cap, segment);
|
||||||
address = db.address() + off;
|
address = ((Buffer)db).address + off;
|
||||||
#if[byte]
|
#if[byte]
|
||||||
cleaner = null;
|
cleaner = null;
|
||||||
#end[byte]
|
#end[byte]
|
||||||
|
|
|
@ -64,7 +64,6 @@ import java.nio.file.Path;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiConsumer;
|
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")
|
@DataProvider(name = "segments")
|
||||||
public static Object[][] segments() throws Throwable {
|
public static Object[][] segments() throws Throwable {
|
||||||
return new Object[][] {
|
return new Object[][] {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue