use of java.lang.invoke.WrongMethodTypeException in project robolectric by robolectric.
the class InvokeDynamicSupport method bindWithFallback.
private static MethodHandle bindWithFallback(RoboCallSite site, MethodHandle mh, MethodHandle fallback) {
SwitchPoint switchPoint = getInvalidator(site.getTheClass());
MethodType type = site.type();
MethodHandle boundFallback = foldArguments(exactInvoker(type), fallback.bindTo(site));
try {
mh = switchPoint.guardWithTest(mh.asType(type), boundFallback);
} catch (WrongMethodTypeException e) {
if (site instanceof MethodCallSite) {
MethodCallSite methodCallSite = (MethodCallSite) site;
throw new RuntimeException("failed to bind " + methodCallSite.thisType() + "." + methodCallSite.getName(), e);
} else {
throw e;
}
}
site.setTarget(mh);
return mh;
}
use of java.lang.invoke.WrongMethodTypeException in project es6draft by anba.
the class NativeCalls method adaptMethodHandle.
private static MethodHandle adaptMethodHandle(String name, MethodType callsiteType, MethodHandle mh) {
try {
MethodHandle target;
if (isSpreadCall(mh, callsiteType)) {
target = forSpreadCall(mh, callsiteType);
} else {
target = mh.asType(callsiteType);
}
if (target != mh) {
MethodHandle invalidArgumentsHandle = invalidCallArgumentsExceptionHandle(name, callsiteType);
target = MethodHandles.catchException(target, ClassCastException.class, invalidArgumentsHandle);
}
return target;
} catch (IllegalArgumentException e) {
return invalidCallHandle(name, callsiteType);
} catch (WrongMethodTypeException e) {
return invalidCallArgumentsHandle(name, callsiteType, e);
}
}
use of java.lang.invoke.WrongMethodTypeException in project openj9 by eclipse.
the class AsTypeTest method doTestConvertFloat.
public void doTestConvertFloat(float v) throws Throwable {
MethodHandle s;
MethodHandle c;
MethodType mt;
Object o = Float.valueOf(v);
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(I)I", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)I", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (int) v, (int) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)I", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (int) v, (int) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(F)F", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)I", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (int) v, (int) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)I", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (int) v, (int) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(J)J", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)J", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (long) v, (long) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)J", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (long) v, (long) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(F)F", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)J", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (long) v, (long) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)J", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (long) v, (long) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(F)F", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)F", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (float) v, (float) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)F", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (float) v, (float) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)F", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (float) v, (float) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(D)D", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)D", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (double) v, (double) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)D", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (double) v, (double) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(F)F", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)D", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (double) v, (double) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)D", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (double) v, (double) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(B)B", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)B", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (byte) v, (byte) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)B", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (byte) v, (byte) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(F)F", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)B", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (byte) v, (byte) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)B", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (byte) v, (byte) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Z)Z", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)Z", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)Z", null);
try {
c = cast(s, mt);
try {
compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(F)F", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)Z", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)Z", null);
try {
c = cast(s, mt);
try {
compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(C)C", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)C", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (char) v, (char) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)C", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (char) v, (char) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(F)F", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)C", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (char) v, (char) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)C", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (char) v, (char) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(S)S", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)S", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (short) v, (short) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)S", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (short) v, (short) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(F)F", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)C", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (char) v, (char) c.invokeExact(this, (float) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)C", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (char) v, (char) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
/* test boxing */
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;F)Ljava/lang/Object;", null);
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
try {
c = cast(s, mt);
try {
compare(s, mt, (float) v, ((Float) (Object) c.invokeExact(this, (float) v)).floatValue());
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Number;)Ljava/lang/Object;", null));
try {
c = cast(s, mt);
try {
compare(s, mt, (float) v, ((Float) (Object) c.invokeExact(this, (float) v)).floatValue());
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/String;)Ljava/lang/Object;", null));
try {
c = cast(s, mt);
noExceptionDuringCast(s, mt);
} catch (WrongMethodTypeException t) {
expectedExceptionDuringCast(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
}
use of java.lang.invoke.WrongMethodTypeException in project openj9 by eclipse.
the class AsTypeTest method doTestConvertChar.
public void doTestConvertChar(char v) throws Throwable {
MethodHandle s;
MethodHandle c;
MethodType mt;
Object o = Character.valueOf(v);
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(I)I", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)I", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (int) v, (int) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)I", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (int) v, (int) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(C)C", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)I", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (int) v, (int) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)I", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (int) v, (int) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(J)J", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)J", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (long) v, (long) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)J", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (long) v, (long) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(C)C", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)J", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (long) v, (long) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)J", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (long) v, (long) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(F)F", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)F", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (float) v, (float) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)F", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (float) v, (float) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(C)C", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)F", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (float) v, (float) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)F", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (float) v, (float) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(D)D", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)D", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (double) v, (double) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)D", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (double) v, (double) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(C)C", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)D", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (double) v, (double) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)D", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (double) v, (double) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(B)B", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)B", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (byte) v, (byte) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)B", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (byte) v, (byte) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(C)C", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)B", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (byte) v, (byte) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)B", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (byte) v, (byte) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Z)Z", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)Z", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)Z", null);
try {
c = cast(s, mt);
try {
compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(C)C", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)Z", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)Z", null);
try {
c = cast(s, mt);
try {
compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(C)C", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)C", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (char) v, (char) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)C", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (char) v, (char) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)C", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (char) v, (char) c.invokeExact(this, (Object) o));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(S)S", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)S", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (short) v, (short) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)S", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (short) v, (short) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(C)C", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)S", null);
try {
c = cast(s, mt);
if (explicit) {
try {
compare(s, mt, (short) v, (short) c.invokeExact(this, (char) v));
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} else {
noExceptionDuringCast(s, mt);
}
} catch (WrongMethodTypeException t) {
wrongMethodType(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;Ljava/lang/Object;)S", null);
try {
c = cast(s, mt);
try {
compare(s, mt, (short) v, (short) c.invokeExact(this, (Object) o));
} catch (ClassCastException t) {
if (explicit) {
exceptionDuringInvoke(s, mt, t);
} else {
expectedExceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
/* test boxing */
mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;C)Ljava/lang/Object;", null);
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Object;)Ljava/lang/Object;", null));
try {
c = cast(s, mt);
try {
compare(s, mt, (int) v, ((Character) (Object) c.invokeExact(this, (char) v)).charValue());
} catch (Throwable t) {
exceptionDuringInvoke(s, mt, t);
}
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/Number;)Ljava/lang/Object;", null));
try {
c = cast(s, mt);
noExceptionDuringCast(s, mt);
} catch (WrongMethodTypeException t) {
expectedExceptionDuringCast(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(Ljava/lang/String;)Ljava/lang/Object;", null));
try {
c = cast(s, mt);
noExceptionDuringCast(s, mt);
} catch (WrongMethodTypeException t) {
expectedExceptionDuringCast(s, mt, t);
} catch (Throwable t) {
exceptionDuringCast(s, mt, t);
}
}
use of java.lang.invoke.WrongMethodTypeException in project openj9 by eclipse.
the class ConstantCallSiteTest method testBasicNegative_ConstantCallSite.
/**
* A basic negative test for ConstantCallSite
* @throws Throwable
*/
@Test(groups = { "level.extended" })
public void testBasicNegative_ConstantCallSite() throws Throwable {
MethodHandle mh = MethodHandles.lookup().findStatic(SamePackageExample.class, "addPublicStatic", MethodType.methodType(int.class, int.class, int.class));
ConstantCallSite ccs = new ConstantCallSite(mh);
boolean wmtHit = false;
try {
int result = (int) ccs.dynamicInvoker().invokeExact(1, 2, 3);
AssertJUnit.assertEquals(3, result);
} catch (WrongMethodTypeException e) {
wmtHit = true;
}
AssertJUnit.assertTrue(wmtHit);
}
Aggregations