mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8317514: Ensure MemorySegment is initialized before touching NativeMemorySegmentImpl
Co-authored-by: Jorn Vernee <jvernee@openjdk.org> Reviewed-by: jvernee
This commit is contained in:
parent
9622de2aa8
commit
7cb2e6d65b
12 changed files with 338 additions and 183 deletions
|
@ -44,9 +44,8 @@ import java.util.Spliterator;
|
|||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
import jdk.internal.foreign.AbstractMemorySegmentImpl;
|
||||
import jdk.internal.foreign.HeapMemorySegmentImpl;
|
||||
import jdk.internal.foreign.MemorySessionImpl;
|
||||
import jdk.internal.foreign.NativeMemorySegmentImpl;
|
||||
import jdk.internal.foreign.SegmentFactories;
|
||||
import jdk.internal.foreign.StringSupport;
|
||||
import jdk.internal.foreign.Utils;
|
||||
import jdk.internal.javac.Restricted;
|
||||
|
@ -1203,7 +1202,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
|
|||
* @return a heap memory segment backed by a byte array.
|
||||
*/
|
||||
static MemorySegment ofArray(byte[] byteArray) {
|
||||
return HeapMemorySegmentImpl.OfByte.fromArray(byteArray);
|
||||
return SegmentFactories.fromArray(byteArray);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1215,7 +1214,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
|
|||
* @return a heap memory segment backed by a char array.
|
||||
*/
|
||||
static MemorySegment ofArray(char[] charArray) {
|
||||
return HeapMemorySegmentImpl.OfChar.fromArray(charArray);
|
||||
return SegmentFactories.fromArray(charArray);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1227,7 +1226,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
|
|||
* @return a heap memory segment backed by a short array.
|
||||
*/
|
||||
static MemorySegment ofArray(short[] shortArray) {
|
||||
return HeapMemorySegmentImpl.OfShort.fromArray(shortArray);
|
||||
return SegmentFactories.fromArray(shortArray);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1239,7 +1238,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
|
|||
* @return a heap memory segment backed by an int array.
|
||||
*/
|
||||
static MemorySegment ofArray(int[] intArray) {
|
||||
return HeapMemorySegmentImpl.OfInt.fromArray(intArray);
|
||||
return SegmentFactories.fromArray(intArray);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1251,7 +1250,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
|
|||
* @return a heap memory segment backed by a float array.
|
||||
*/
|
||||
static MemorySegment ofArray(float[] floatArray) {
|
||||
return HeapMemorySegmentImpl.OfFloat.fromArray(floatArray);
|
||||
return SegmentFactories.fromArray(floatArray);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1263,7 +1262,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
|
|||
* @return a heap memory segment backed by a long array.
|
||||
*/
|
||||
static MemorySegment ofArray(long[] longArray) {
|
||||
return HeapMemorySegmentImpl.OfLong.fromArray(longArray);
|
||||
return SegmentFactories.fromArray(longArray);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1275,13 +1274,13 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
|
|||
* @return a heap memory segment backed by a double array.
|
||||
*/
|
||||
static MemorySegment ofArray(double[] doubleArray) {
|
||||
return HeapMemorySegmentImpl.OfDouble.fromArray(doubleArray);
|
||||
return SegmentFactories.fromArray(doubleArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* A zero-length native segment modelling the {@code NULL} address.
|
||||
* A zero-length native segment modelling the {@code NULL} address. Equivalent to {@code MemorySegment.ofAddress(0L)}.
|
||||
*/
|
||||
MemorySegment NULL = new NativeMemorySegmentImpl();
|
||||
MemorySegment NULL = MemorySegment.ofAddress(0L);
|
||||
|
||||
/**
|
||||
* Creates a zero-length native segment from the given {@linkplain #address() address value}.
|
||||
|
@ -1295,7 +1294,7 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
|
|||
* @return a zero-length native segment with the given address.
|
||||
*/
|
||||
static MemorySegment ofAddress(long address) {
|
||||
return NativeMemorySegmentImpl.makeNativeSegmentUnchecked(address, 0);
|
||||
return SegmentFactories.makeNativeSegmentUnchecked(address, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue