-
Bug
-
Resolution: Fixed
-
P3
-
None
-
repo-panama
Given a native function with following prototype,
int sum_ptr(int *ar, int len);
Calling it from Java with
Array<Integer> ar = scope.allocateArray(NativeTypes.INT, 0);
fap.sum_ptr(ar.elementPointer(), 0);
will cause following exception to be thrown,
java.lang.IllegalStateException: offset: 0, region length: 0
at java.base/jdk.internal.foreign.memory.MemoryBoundInfo.checkRange(MemoryBoundInfo.java:101)
at java.base/jdk.internal.foreign.memory.BoundedPointer.checkRange(BoundedPointer.java:212)
at java.base/jdk.internal.foreign.memory.BoundedPointer.checkAccess(BoundedPointer.java:232)
at java.base/jdk.internal.foreign.memory.BoundedPointer.checkAccess(BoundedPointer.java:236)
at java.base/jdk.internal.foreign.memory.BoundedPointer.addr(BoundedPointer.java:108)
at java.base/jdk.internal.foreign.abi.DirectSignatureShuffler.pointerToLong(DirectSignatureShuffler.java:319)
at test.arrayparam.funcArrayParam_h$Impl/0x00000007c0374440.sum_ptr(Unknown Source)
at FuncArrayParamTest.testSumPtr(FuncArrayParamTest.java:82)
int sum_ptr(int *ar, int len);
Calling it from Java with
Array<Integer> ar = scope.allocateArray(NativeTypes.INT, 0);
fap.sum_ptr(ar.elementPointer(), 0);
will cause following exception to be thrown,
java.lang.IllegalStateException: offset: 0, region length: 0
at java.base/jdk.internal.foreign.memory.MemoryBoundInfo.checkRange(MemoryBoundInfo.java:101)
at java.base/jdk.internal.foreign.memory.BoundedPointer.checkRange(BoundedPointer.java:212)
at java.base/jdk.internal.foreign.memory.BoundedPointer.checkAccess(BoundedPointer.java:232)
at java.base/jdk.internal.foreign.memory.BoundedPointer.checkAccess(BoundedPointer.java:236)
at java.base/jdk.internal.foreign.memory.BoundedPointer.addr(BoundedPointer.java:108)
at java.base/jdk.internal.foreign.abi.DirectSignatureShuffler.pointerToLong(DirectSignatureShuffler.java:319)
at test.arrayparam.funcArrayParam_h$Impl/0x00000007c0374440.sum_ptr(Unknown Source)
at FuncArrayParamTest.testSumPtr(FuncArrayParamTest.java:82)