mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8308645: Javadoc of FFM API needs to be refreshed
8309398: ValueLayout:: arrayElementVarHandle doesn't throws UnsupportedOperationException - if byteAlignment() > byteSize() 8308812: SequenceLayout::withElementCount(long elementCount) doesn't throw IllegalArgumentException - if elementCount < 0 for some cases Reviewed-by: jvernee
This commit is contained in:
parent
07275072aa
commit
a6ad42e00e
28 changed files with 826 additions and 607 deletions
|
@ -186,16 +186,16 @@ class Snippets {
|
|||
}
|
||||
}
|
||||
|
||||
FunctionDescriptor compareDesc = FunctionDescriptor.of(JAVA_INT,
|
||||
FunctionDescriptor comparDesc = FunctionDescriptor.of(JAVA_INT,
|
||||
ADDRESS.withTargetLayout(JAVA_INT),
|
||||
ADDRESS.withTargetLayout(JAVA_INT));
|
||||
MethodHandle compareHandle = MethodHandles.lookup()
|
||||
MethodHandle comparHandle = MethodHandles.lookup()
|
||||
.findStatic(Qsort.class, "qsortCompare",
|
||||
compareDesc.toMethodType());
|
||||
comparDesc.toMethodType());
|
||||
|
||||
|
||||
try (Arena arena = Arena.ofConfined()) {
|
||||
MemorySegment compareFunc = linker.upcallStub(compareHandle, compareDesc, arena);
|
||||
MemorySegment compareFunc = linker.upcallStub(comparHandle, comparDesc, arena);
|
||||
MemorySegment array = arena.allocateArray(JAVA_INT, 0, 9, 3, 4, 6, 5, 1, 8, 2, 7);
|
||||
qsort.invokeExact(array, 10L, 4L, compareFunc);
|
||||
int[] sorted = array.toArray(JAVA_INT); // [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
|
||||
|
@ -400,7 +400,7 @@ class Snippets {
|
|||
.findStatic(Math.class, "multiplyExact",
|
||||
MethodType.methodType(long.class, long.class, long.class));
|
||||
intHandle = MethodHandles.filterCoordinates(intHandle, 1,
|
||||
MethodHandles.insertArguments(multiplyExact, 0, 4L));
|
||||
MethodHandles.insertArguments(multiplyExact, 0, ValueLayout.JAVA_INT.byteSize()));
|
||||
int value = (int) intHandle.get(segment, 3L); // get int element at offset 3 * 4 = 12
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue