use of java.lang.constant.DynamicCallSiteDesc in project openj9 by eclipse.
the class Test_DynamicCallSiteDesc method testDynamicCallSiteDescResolveCallSiteDesc.
/*
* Test Java 12 API DynamicCallSiteDesc.resolveCallSiteDesc()
*/
@Test(groups = { "level.sanity" })
public void testDynamicCallSiteDescResolveCallSiteDesc() throws Throwable {
/* setup */
ClassDesc bsmOwnerDesc = Test_DynamicCallSiteDesc.class.describeConstable().orElseThrow();
ClassDesc bsmRetTypeDesc = ConstantCallSite.class.describeConstable().orElseThrow();
MethodTypeDesc handleType = MethodType.methodType(void.class).describeConstable().orElseThrow();
/* describe and resolve callsite */
DirectMethodHandleDesc bsm = ConstantDescs.ofCallsiteBootstrap(bsmOwnerDesc, "bsm", bsmRetTypeDesc);
DynamicCallSiteDesc desc = DynamicCallSiteDesc.of(bsm, fieldName, handleType);
CallSite resolvedSite = desc.resolveCallSiteDesc(MethodHandles.lookup());
/* verify that the callsite contains the expected MethodHandle */
logger.debug("testDynamicCallSiteDescResolveCallSiteDesc: resolved CallSite type is: " + resolvedSite.type().toMethodDescriptorString());
Assert.assertTrue(fieldName.equals((String) resolvedSite.getTarget().invokeExact()));
}
Aggregations