use of com.oracle.truffle.api.interop.UnknownIdentifierException in project graal by oracle.
the class ValidTruffleObject15Test method expectUnsupportedSpecializationException.
@Test(expected = UnsupportedSpecializationException.class)
public void expectUnsupportedSpecializationException() {
ValidTruffleObject15 object = new ValidTruffleObject15();
Node read = Message.WRITE.createNode();
try {
ForeignAccess.sendWrite(read, object, "name", new UnknownObject());
} catch (UnknownIdentifierException e) {
Assert.fail();
} catch (UnsupportedMessageException e) {
Assert.fail();
} catch (UnsupportedTypeException e) {
Assert.fail();
}
}
use of com.oracle.truffle.api.interop.UnknownIdentifierException in project graal by oracle.
the class TestMemberAccess method testMethods.
@Test
public void testMethods() throws InvocationTargetException, IllegalAccessException, InteropException {
TestClass t = new TestClass();
Method[] methods = t.getClass().getDeclaredMethods();
for (Method m : methods) {
if (m.getParameterCount() == 0) {
m.setAccessible(true);
String name = m.getName();
if (name.startsWith("method")) {
boolean isPublic = (m.getModifiers() & Modifier.PUBLIC) != 0;
boolean wasUIE = false;
try {
testForValue(name, m.invoke(t));
} catch (UnknownIdentifierException e) {
if (isPublic) {
throw e;
}
wasUIE = true;
}
if (!isPublic && !wasUIE) {
fail("expected UnknownIdentifierException when accessing method: " + name);
}
}
}
}
}
use of com.oracle.truffle.api.interop.UnknownIdentifierException in project graal by oracle.
the class TestMemberAccess method getValueFromMember.
private Object getValueFromMember(Class<?> javaClazz, String name, Object... parameters) throws InteropException {
TruffleObject clazz = JavaInterop.asTruffleObject(javaClazz);
Object o = ForeignAccess.sendNew(newNode, clazz);
try {
o = ForeignAccess.sendRead(readNode, (TruffleObject) o, name);
} catch (UnknownIdentifierException e) {
o = ForeignAccess.sendRead(readNode, clazz, name);
}
if (o instanceof TruffleObject && ForeignAccess.sendIsExecutable(isExecutableNode, (TruffleObject) o)) {
o = ForeignAccess.sendExecute(executeNode, (TruffleObject) o, parameters);
}
if (o instanceof TruffleObject && ForeignAccess.sendIsBoxed(isBoxedNode, (TruffleObject) o)) {
o = ForeignAccess.sendUnbox(unboxNode, (TruffleObject) o);
}
return o;
}
use of com.oracle.truffle.api.interop.UnknownIdentifierException in project graal by oracle.
the class VisibilityTest method invokeRun.
private static Object invokeRun(Object obj, Class<?> methodClass, Object... args) throws InteropException {
TruffleObject receiver = JavaInterop.asTruffleObject(obj);
try {
Object result = ForeignAccess.sendInvoke(Message.createInvoke(0).createNode(), receiver, "run", args);
Assert.assertSame(methodClass, run);
return result;
} catch (UnknownIdentifierException uie) {
Assert.assertSame(methodClass, null);
Assert.assertNull(run);
return null;
} finally {
run = null;
}
}
use of com.oracle.truffle.api.interop.UnknownIdentifierException in project sulong by graalvm.
the class LLVMTruffleInvoke method doInvoke.
@ExplodeLoop
private Object doInvoke(VirtualFrame frame, TruffleObject value, String id, ContextReference<LLVMContext> contextReference, LLVMGetStackNode getStack) {
Object[] evaluatedArgs = new Object[args.length];
for (int i = 0; i < args.length; i++) {
evaluatedArgs[i] = prepareValuesForEscape[i].executeWithTarget(args[i].executeGeneric(frame));
}
try {
LLVMContext context = contextReference.get();
LLVMStack stack = getStack.executeWithTarget(getThreadingStack(context), Thread.currentThread());
Object rawValue;
try (StackPointer save = stack.newFrame()) {
rawValue = ForeignAccess.sendInvoke(foreignInvoke, value, id, evaluatedArgs);
}
return toLLVM.executeWithTarget(rawValue);
} catch (UnknownIdentifierException | UnsupportedMessageException | UnsupportedTypeException | ArityException e) {
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException(e);
}
}
Aggregations