-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P3
-
Affects Version/s: repo-panama
-
Component/s: core-libs
A call to SegmentAllocator::allocateArray, such as:
allocator.allocateArray(JAVA_LONG, 10);
Is somewhat ambiguous. It is not clear whether this should create an uninitialized long array with 10 elements, or a long array with a single element initialized to '10'.
i.e. either of the following overloads of allocateArray is applicable:
default MemorySegment allocateArray(MemoryLayout elementLayout, long count)
default MemorySegment allocateArray(ValueLayout.OfLong elementLayout, long... elements)
Overload resolution picks the former.
We could rename one of these methods to disambiguate a use case such as this.
allocator.allocateArray(JAVA_LONG, 10);
Is somewhat ambiguous. It is not clear whether this should create an uninitialized long array with 10 elements, or a long array with a single element initialized to '10'.
i.e. either of the following overloads of allocateArray is applicable:
default MemorySegment allocateArray(MemoryLayout elementLayout, long count)
default MemorySegment allocateArray(ValueLayout.OfLong elementLayout, long... elements)
Overload resolution picks the former.
We could rename one of these methods to disambiguate a use case such as this.