Search in sources :

Example 6 with VolatileCallSite

use of java.lang.invoke.VolatileCallSite in project openj9 by eclipse.

the class VolatileCallSiteTest method testType_VolatileCallSite.

/**
 * Test for VolatileCallSite.type()
 * @throws Throwable
 */
@Test(groups = { "level.extended" })
public void testType_VolatileCallSite() throws Throwable {
    MethodType mt = MethodType.methodType(String.class);
    MethodHandle mh = MethodHandles.lookup().findStatic(SamePackageExample.class, "returnOne", mt);
    VolatileCallSite vcs = new VolatileCallSite(mh);
    AssertJUnit.assertEquals(mt, vcs.type());
}
Also used : VolatileCallSite(java.lang.invoke.VolatileCallSite) MethodType(java.lang.invoke.MethodType) MethodHandle(java.lang.invoke.MethodHandle) Test(org.testng.annotations.Test)

Example 7 with VolatileCallSite

use of java.lang.invoke.VolatileCallSite in project openj9 by eclipse.

the class VolatileCallSiteTest method testIllegalState_dynamicInvoker_VolatileCallSite.

/**
 * Test for validating default MethodHandle behavior of VolatileCallSite
 * using VolatileCallSite.dynamicInvoker.invoke()
 * @throws Throwable
 */
@Test(groups = { "level.extended" })
public void testIllegalState_dynamicInvoker_VolatileCallSite() throws Throwable {
    MethodType mt = MethodType.methodType(void.class);
    VolatileCallSite vcs = new VolatileCallSite(mt);
    boolean iseHit = false;
    try {
        vcs.dynamicInvoker().invoke();
    } catch (IllegalStateException e) {
        iseHit = true;
    }
    AssertJUnit.assertTrue(iseHit);
}
Also used : VolatileCallSite(java.lang.invoke.VolatileCallSite) MethodType(java.lang.invoke.MethodType) Test(org.testng.annotations.Test)

Aggregations

VolatileCallSite (java.lang.invoke.VolatileCallSite)7 Test (org.testng.annotations.Test)7 MethodHandle (java.lang.invoke.MethodHandle)5 MethodType (java.lang.invoke.MethodType)4 SwitchPoint (java.lang.invoke.SwitchPoint)2 WrongMethodTypeException (java.lang.invoke.WrongMethodTypeException)1