use of jdk.incubator.foreign.Addressable in project openj9 by eclipse.
the class InvalidDownCallTests method test_mismatchedLayoutSizeForMemoryAddress.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Mismatched size .*")
public void test_mismatchedLayoutSizeForMemoryAddress() throws Throwable {
/* Temporarily disable the default library loading on AIX till we figure out a way
* around to handle the case as the official implementation in OpenJDK17 doesn't
* help to load the static libray (libc.a).
*/
if (isAixOS) {
throw new IllegalArgumentException("Mismatched size ");
} else {
Addressable functionSymbol = defaultLibLookup.lookup("strlen").get();
MethodType mt = MethodType.methodType(long.class, MemoryAddress.class);
FunctionDescriptor fd = FunctionDescriptor.of(longLayout, MemoryLayouts.BITS_16_LE);
MethodHandle mh = clinker.downcallHandle(functionSymbol, mt, fd);
fail("Failed to throw out IllegalArgumentException in the case of the mismatched layout size");
}
}
use of jdk.incubator.foreign.Addressable in project openj9 by eclipse.
the class InvalidDownCallTests method test_mismatchedLongArgLayoutWithDoubleType.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Mismatch between the layout .*")
public void test_mismatchedLongArgLayoutWithDoubleType() throws Throwable {
MethodType mt = MethodType.methodType(double.class, double.class, double.class);
FunctionDescriptor fd = FunctionDescriptor.of(C_DOUBLE, C_DOUBLE, longLayout);
Addressable functionSymbol = nativeLibLookup.lookup("add2Doubles").get();
MethodHandle mh = clinker.downcallHandle(functionSymbol, mt, fd);
fail("Failed to throw out IllegalArgumentException in the case of the mismatched long layout");
}
use of jdk.incubator.foreign.Addressable in project openj9 by eclipse.
the class InvalidDownCallTests method test_mismatchedShortReturnTypeWithIntReturnLayout.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Mismatched size .*")
public void test_mismatchedShortReturnTypeWithIntReturnLayout() throws Throwable {
MethodType mt = MethodType.methodType(short.class, int.class, int.class);
FunctionDescriptor fd = FunctionDescriptor.of(C_INT, C_INT, C_INT);
Addressable functionSymbol = nativeLibLookup.lookup("add2Ints").get();
MethodHandle mh = clinker.downcallHandle(functionSymbol, mt, fd);
fail("Failed to throw out IllegalArgumentException in the case of the non-void return type");
}
use of jdk.incubator.foreign.Addressable in project openj9 by eclipse.
the class InvalidDownCallTests method test_unsupportedStringType.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".* neither primitive nor .*")
public void test_unsupportedStringType() throws Throwable {
MethodType mt = MethodType.methodType(int.class, int.class, String.class);
FunctionDescriptor fd = FunctionDescriptor.of(C_INT, C_INT, MemoryLayouts.BITS_64_LE);
Addressable functionSymbol = nativeLibLookup.lookup("add2Ints").get();
MethodHandle mh = clinker.downcallHandle(functionSymbol, mt, fd);
fail("Failed to throw out IllegalArgumentException in the case of the unsupported String type");
}
use of jdk.incubator.foreign.Addressable in project openj9 by eclipse.
the class InvalidDownCallTests method test_mismatchedVoidReturnTypeWithIntReturnLayout.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Mismatch between the layout .*")
public void test_mismatchedVoidReturnTypeWithIntReturnLayout() throws Throwable {
MethodType mt = MethodType.methodType(void.class, int.class, int.class);
FunctionDescriptor fd = FunctionDescriptor.of(C_INT, C_INT, C_INT);
Addressable functionSymbol = nativeLibLookup.lookup("add2Ints").get();
MethodHandle mh = clinker.downcallHandle(functionSymbol, mt, fd);
fail("Failed to throw out IllegalArgumentException in the case of the void return type");
}
Aggregations