Search in sources :

Example 6 with ReflectionLibrary

use of com.oracle.truffle.api.library.ReflectionLibrary in project graal by oracle.

the class ReflectionTest method testReflectionDefault.

@Test
public void testReflectionDefault() throws Exception {
    Object receiver = new Object();
    ReflectionLibrary reflection = createLibrary(ReflectionLibrary.class, receiver);
    Message primitive = Message.resolve(ReflectionTestLibrary.class, "primitive");
    Message voidReturn = Message.resolve(ReflectionTestLibrary.class, "voidReturn");
    Assert.assertEquals(42, reflection.send(receiver, primitive, 12));
    try {
        reflection.send(receiver, voidReturn);
        Assert.fail();
    } catch (AbstractMethodError e) {
    }
}
Also used : Message(com.oracle.truffle.api.library.Message) ExportMessage(com.oracle.truffle.api.library.ExportMessage) ReflectionLibrary(com.oracle.truffle.api.library.ReflectionLibrary) Test(org.junit.Test) AbstractParametrizedLibraryTest(com.oracle.truffle.api.test.AbstractParametrizedLibraryTest)

Aggregations

ReflectionLibrary (com.oracle.truffle.api.library.ReflectionLibrary)6 Test (org.junit.Test)4 ExportMessage (com.oracle.truffle.api.library.ExportMessage)3 Message (com.oracle.truffle.api.library.Message)3 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)2 AbstractParametrizedLibraryTest (com.oracle.truffle.api.test.AbstractParametrizedLibraryTest)2 AbstractTruffleException (com.oracle.truffle.api.exception.AbstractTruffleException)1 AbstractLibraryTest (com.oracle.truffle.api.test.AbstractLibraryTest)1 Context (org.graalvm.polyglot.Context)1