use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class JavaInteropTest method conversionToClass2.
@Test
public void conversionToClass2() {
TruffleObject expected = JavaInterop.asTruffleObject(Class.class);
TruffleObject computed = JavaInterop.toJavaClass(JavaInterop.asTruffleObject(Data.class));
assertEquals("Both class objects are the same", expected, computed);
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class JavaInteropTest method executableAsFunctionalInterface2.
@Test
public void executableAsFunctionalInterface2() throws Exception {
TruffleObject executable = new FunctionObject();
FunctionalWithObjectMethodOverrides f = JavaInterop.asJavaFunction(FunctionalWithObjectMethodOverrides.class, executable);
assertEquals(50, f.call(13, 37));
f.hashCode();
f.equals(null);
f.toString();
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class JavaInteropTest method testExecuteClass.
@Test
public void testExecuteClass() {
TruffleObject hashMapClass = JavaInterop.asTruffleObject(HashMap.class);
assertThrowsExceptionWithCause(() -> ForeignAccess.sendExecute(Message.createExecute(0).createNode(), hashMapClass), UnsupportedMessageException.class);
assertFalse("IS_EXECUTABLE", ForeignAccess.sendIsExecutable(Message.IS_EXECUTABLE.createNode(), hashMapClass));
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class JavaInteropTest method conversionToClassNull.
@Test
public void conversionToClassNull() {
TruffleObject expected = JavaInterop.asTruffleObject(null);
TruffleObject computed = JavaInterop.toJavaClass(expected);
assertEquals(expected, computed);
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class JavaInteropTest method invokeJavaLangObjectFields.
@Test
public void invokeJavaLangObjectFields() throws InteropException {
Object string = ForeignAccess.sendInvoke(Message.createInvoke(0).createNode(), obj, "toString");
assertTrue(string instanceof String && ((String) string).startsWith(Data.class.getName() + "@"));
Object clazz = ForeignAccess.sendInvoke(Message.createInvoke(0).createNode(), obj, "getClass");
assertTrue(clazz instanceof TruffleObject && JavaInterop.asJavaObject((TruffleObject) clazz) == Data.class);
assertEquals(true, ForeignAccess.sendInvoke(Message.createInvoke(1).createNode(), obj, "equals", obj));
assertTrue(ForeignAccess.sendInvoke(Message.createInvoke(0).createNode(), obj, "hashCode") instanceof Integer);
for (String m : new String[] { "notify", "notifyAll", "wait" }) {
assertThrowsExceptionWithCause(() -> ForeignAccess.sendInvoke(Message.createInvoke(0).createNode(), obj, m), IllegalMonitorStateException.class);
}
}
Aggregations