8289228: SegmentAllocator::allocateArray null handling is too lax
Reviewed-by: jvernee, psandoz
This commit is contained in:
parent
b4490386fe
commit
adbd200dc5
@ -282,8 +282,9 @@ public interface SegmentAllocator {
|
||||
|
||||
private <Z> MemorySegment copyArrayWithSwapIfNeeded(Z array, ValueLayout elementLayout,
|
||||
Function<Z, MemorySegment> heapSegmentFactory) {
|
||||
Objects.requireNonNull(array);
|
||||
Objects.requireNonNull(elementLayout);
|
||||
int size = array == null ? 0 : Array.getLength(array);
|
||||
int size = Array.getLength(array);
|
||||
MemorySegment addr = allocateArray(elementLayout, size);
|
||||
if (size > 0) {
|
||||
MemorySegment.copy(heapSegmentFactory.apply(array), elementLayout, 0,
|
||||
|
@ -121,21 +121,7 @@ public class TestNulls {
|
||||
"java.lang.foreign.ValueLayout$OfLong/withAttribute(java.lang.String,java.lang.constant.Constable)/1/0",
|
||||
"java.lang.foreign.ValueLayout$OfDouble/withAttribute(java.lang.String,java.lang.constant.Constable)/1/0",
|
||||
"java.lang.foreign.GroupLayout/withAttribute(java.lang.String,java.lang.constant.Constable)/1/0",
|
||||
"java.lang.foreign.FunctionDescriptor/withAttribute(java.lang.String,java.lang.constant.Constable)/1/0",
|
||||
"java.lang.foreign.SegmentAllocator/allocateArray(java.lang.foreign.ValueLayout$OfByte,byte[])/1/0",
|
||||
"java.lang.foreign.SegmentAllocator/allocateArray(java.lang.foreign.ValueLayout$OfShort,short[])/1/0",
|
||||
"java.lang.foreign.SegmentAllocator/allocateArray(java.lang.foreign.ValueLayout$OfChar,char[])/1/0",
|
||||
"java.lang.foreign.SegmentAllocator/allocateArray(java.lang.foreign.ValueLayout$OfInt,int[])/1/0",
|
||||
"java.lang.foreign.SegmentAllocator/allocateArray(java.lang.foreign.ValueLayout$OfFloat,float[])/1/0",
|
||||
"java.lang.foreign.SegmentAllocator/allocateArray(java.lang.foreign.ValueLayout$OfLong,long[])/1/0",
|
||||
"java.lang.foreign.SegmentAllocator/allocateArray(java.lang.foreign.ValueLayout$OfDouble,double[])/1/0",
|
||||
"java.lang.foreign.MemorySession/allocateArray(java.lang.foreign.ValueLayout$OfByte,byte[])/1/0",
|
||||
"java.lang.foreign.MemorySession/allocateArray(java.lang.foreign.ValueLayout$OfShort,short[])/1/0",
|
||||
"java.lang.foreign.MemorySession/allocateArray(java.lang.foreign.ValueLayout$OfChar,char[])/1/0",
|
||||
"java.lang.foreign.MemorySession/allocateArray(java.lang.foreign.ValueLayout$OfInt,int[])/1/0",
|
||||
"java.lang.foreign.MemorySession/allocateArray(java.lang.foreign.ValueLayout$OfFloat,float[])/1/0",
|
||||
"java.lang.foreign.MemorySession/allocateArray(java.lang.foreign.ValueLayout$OfLong,long[])/1/0",
|
||||
"java.lang.foreign.MemorySession/allocateArray(java.lang.foreign.ValueLayout$OfDouble,double[])/1/0"
|
||||
"java.lang.foreign.FunctionDescriptor/withAttribute(java.lang.String,java.lang.constant.Constable)/1/0"
|
||||
);
|
||||
|
||||
static final Set<String> OBJECT_METHODS = Stream.of(Object.class.getMethods())
|
||||
|
Loading…
Reference in New Issue
Block a user