use of jdk.incubator.foreign.Addressable in project openj9 by eclipse.
the class PrimitiveTypeTests2 method test_addTwoBoolsWithOr_fromMemAddr_2.
@Test
public void test_addTwoBoolsWithOr_fromMemAddr_2() throws Throwable {
MethodType mt = MethodType.methodType(boolean.class, boolean.class, boolean.class);
FunctionDescriptor fd = FunctionDescriptor.of(C_CHAR, C_CHAR, C_CHAR);
Addressable functionSymbol = nativeLibLookup.lookup("add2BoolsWithOr").get();
MemoryAddress memAddr = functionSymbol.address();
MethodHandle mh = clinker.downcallHandle(memAddr, allocator, mt, fd);
boolean result = (boolean) mh.invokeExact(true, false);
Assert.assertEquals(result, true);
}
use of jdk.incubator.foreign.Addressable in project openj9 by eclipse.
the class PrimitiveTypeTests2 method test_addTwoLongs_fromMemAddr_2.
@Test
public void test_addTwoLongs_fromMemAddr_2() throws Throwable {
MethodType mt = MethodType.methodType(long.class, long.class, long.class);
FunctionDescriptor fd = FunctionDescriptor.of(longLayout, longLayout, longLayout);
Addressable functionSymbol = nativeLibLookup.lookup("add2Longs").get();
MemoryAddress memAddr = functionSymbol.address();
MethodHandle mh = clinker.downcallHandle(memAddr, allocator, mt, fd);
long result = (long) mh.invokeExact(57424L, 698235L);
Assert.assertEquals(result, 755659L);
}
use of jdk.incubator.foreign.Addressable in project openj9 by eclipse.
the class InvalidDownCallTests method test_mismatchedBoolArgWithShortLayout.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Mismatched size .*")
public void test_mismatchedBoolArgWithShortLayout() throws Throwable {
MethodType mt = MethodType.methodType(boolean.class, boolean.class, boolean.class);
FunctionDescriptor fd = FunctionDescriptor.of(C_CHAR, C_SHORT, C_CHAR);
Addressable functionSymbol = nativeLibLookup.lookup("add2BoolsWithOr").get();
MethodHandle mh = clinker.downcallHandle(functionSymbol, mt, fd);
fail("Failed to throw out IllegalArgumentException in the case of the mismatched layout");
}
use of jdk.incubator.foreign.Addressable in project openj9 by eclipse.
the class InvalidDownCallTests method test_mismatchedIntArgTypeWithLongLayout.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Mismatched size .*")
public void test_mismatchedIntArgTypeWithLongLayout() throws Throwable {
MethodType mt = MethodType.methodType(long.class, int.class, long.class);
FunctionDescriptor fd = FunctionDescriptor.of(longLayout, longLayout, longLayout);
Addressable functionSymbol = nativeLibLookup.lookup("add2Longs").get();
MethodHandle mh = clinker.downcallHandle(functionSymbol, mt, fd);
fail("Failed to throw out IllegalArgumentException in the case of the mismatched int type");
}
use of jdk.incubator.foreign.Addressable in project openj9 by eclipse.
the class InvalidDownCallTests method test_invalidBooleanTypeOnReturn.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The return type must be .*")
public void test_invalidBooleanTypeOnReturn() throws Throwable {
MethodType mt = MethodType.methodType(Boolean.class, boolean.class, boolean.class);
FunctionDescriptor fd = FunctionDescriptor.of(C_CHAR, C_CHAR, C_CHAR);
Addressable functionSymbol = nativeLibLookup.lookup("add2BoolsWithOr").get();
MethodHandle mh = clinker.downcallHandle(functionSymbol, mt, fd);
fail("Failed to throw out IllegalArgumentException in the case of the Boolean return type");
}
Aggregations