Search in sources :

Example 6 with WrongMethodTypeException

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

the class AsTypeTest method doTestConvertLong.

public void doTestConvertLong(long v) throws Throwable {
    MethodHandle s;
    MethodHandle c;
    MethodType mt;
    Object o = Long.valueOf(v);
    s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(I)I", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;J)I", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (int) v, (int) c.invokeExact(this, (long) 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("(J)J", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;J)I", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (int) v, (int) c.invokeExact(this, (long) 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;J)J", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (long) v, (long) c.invokeExact(this, (long) 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("(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;J)F", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (float) v, (float) c.invokeExact(this, (long) 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("(J)J", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;J)F", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (float) v, (float) c.invokeExact(this, (long) 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;J)D", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (double) v, (double) c.invokeExact(this, (long) 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("(J)J", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;J)D", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (double) v, (double) c.invokeExact(this, (long) 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;J)B", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (byte) v, (byte) c.invokeExact(this, (long) 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("(J)J", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;J)B", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (byte) v, (byte) c.invokeExact(this, (long) 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;J)Z", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (long) 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("(J)J", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;J)Z", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (long) 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;J)C", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (char) v, (char) c.invokeExact(this, (long) 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("(J)J", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;J)C", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (char) v, (char) c.invokeExact(this, (long) 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;J)S", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (short) v, (short) c.invokeExact(this, (long) 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("(J)J", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;J)S", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (short) v, (short) c.invokeExact(this, (long) 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;J)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, (long) v, ((Long) (Object) c.invokeExact(this, (long) v)).longValue());
        } 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, (long) v, ((Long) (Object) c.invokeExact(this, (long) v)).longValue());
        } 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);
    }
}
Also used : MethodType(java.lang.invoke.MethodType) WrongMethodTypeException(java.lang.invoke.WrongMethodTypeException) MethodHandle(java.lang.invoke.MethodHandle)

Example 7 with WrongMethodTypeException

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

the class AsTypeTest method doTestConvertDouble.

public void doTestConvertDouble(double v) throws Throwable {
    MethodHandle s;
    MethodHandle c;
    MethodType mt;
    Object o = Double.valueOf(v);
    s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(I)I", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;D)I", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (int) v, (int) c.invokeExact(this, (double) 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("(D)D", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;D)I", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (int) v, (int) c.invokeExact(this, (double) 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;D)J", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (long) v, (long) c.invokeExact(this, (double) 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("(D)D", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;D)J", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (long) v, (long) c.invokeExact(this, (double) 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;D)F", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (float) v, (float) c.invokeExact(this, (double) 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;)F", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (float) v, (float) 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("(D)D", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;D)F", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (float) v, (float) c.invokeExact(this, (double) 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;)F", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (float) v, (float) 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("(D)D", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;D)D", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (double) v, (double) c.invokeExact(this, (double) 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("(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;D)B", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (byte) v, (byte) c.invokeExact(this, (double) 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("(D)D", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;D)B", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (byte) v, (byte) c.invokeExact(this, (double) 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;D)Z", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (double) 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("(D)D", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;D)Z", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (double) 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;D)C", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (char) v, (char) c.invokeExact(this, (double) 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("(D)D", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;D)C", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (char) v, (char) c.invokeExact(this, (double) 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;D)S", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (short) v, (short) c.invokeExact(this, (double) 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("(D)D", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;D)S", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (short) v, (short) c.invokeExact(this, (double) 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;D)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, (double) v, ((Double) (Object) c.invokeExact(this, (double) v)).doubleValue());
        } 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, (double) v, ((Double) (Object) c.invokeExact(this, (double) v)).doubleValue());
        } 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);
    }
}
Also used : MethodType(java.lang.invoke.MethodType) WrongMethodTypeException(java.lang.invoke.WrongMethodTypeException) MethodHandle(java.lang.invoke.MethodHandle)

Example 8 with WrongMethodTypeException

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

the class AsTypeTest method doTestConvertInt.

public void doTestConvertInt(int v) throws Throwable {
    MethodHandle s;
    MethodHandle c;
    MethodType mt;
    Object o = Integer.valueOf(v);
    s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(I)I", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;I)I", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (int) v, (int) c.invokeExact(this, (int) 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("(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;I)J", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (long) v, (long) c.invokeExact(this, (int) 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("(I)I", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;I)J", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (long) v, (long) c.invokeExact(this, (int) 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;I)F", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (float) v, (float) c.invokeExact(this, (int) 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("(I)I", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;I)F", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (float) v, (float) c.invokeExact(this, (int) 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;I)D", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (double) v, (double) c.invokeExact(this, (int) 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("(I)I", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;I)D", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (double) v, (double) c.invokeExact(this, (int) 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;I)B", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (byte) v, (byte) c.invokeExact(this, (int) 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("(I)I", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;I)B", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (byte) v, (byte) c.invokeExact(this, (int) 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;I)Z", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (int) 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("(I)I", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;I)Z", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (int) 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("(C)C", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;I)C", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (char) v, (char) c.invokeExact(this, (int) 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("(I)I", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;I)C", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (char) v, (char) c.invokeExact(this, (int) 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("(S)S", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;I)S", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (short) v, (short) c.invokeExact(this, (int) 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("(I)I", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;I)S", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (short) v, (short) c.invokeExact(this, (int) 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);
    }
    /* test boxing */
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;I)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, ((Integer) (Object) c.invokeExact(this, (int) v)).intValue());
        } 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, (int) v, ((Integer) (Object) c.invokeExact(this, (int) v)).intValue());
        } 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);
    }
}
Also used : MethodType(java.lang.invoke.MethodType) WrongMethodTypeException(java.lang.invoke.WrongMethodTypeException) MethodHandle(java.lang.invoke.MethodHandle)

Example 9 with WrongMethodTypeException

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

the class AsTypeTest method doTestConvertShort.

public void doTestConvertShort(short v) throws Throwable {
    MethodHandle s;
    MethodHandle c;
    MethodType mt;
    Object o = Short.valueOf(v);
    s = MethodHandles.lookup().findVirtual(AsTypeTest.class, "doTest", MethodType.fromMethodDescriptorString("(I)I", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;S)I", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (int) v, (int) c.invokeExact(this, (short) 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("(S)S", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;S)I", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (int) v, (int) c.invokeExact(this, (short) 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;S)J", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (long) v, (long) c.invokeExact(this, (short) 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("(S)S", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;S)J", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (long) v, (long) c.invokeExact(this, (short) 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;S)F", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (float) v, (float) c.invokeExact(this, (short) 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("(S)S", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;S)F", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (float) v, (float) c.invokeExact(this, (short) 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;S)D", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (double) v, (double) c.invokeExact(this, (short) 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("(S)S", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;S)D", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (double) v, (double) c.invokeExact(this, (short) 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;S)B", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (byte) v, (byte) c.invokeExact(this, (short) 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("(S)S", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;S)B", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (byte) v, (byte) c.invokeExact(this, (short) 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;S)Z", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (short) 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("(S)S", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;S)Z", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, castToBoolean(v), (boolean) c.invokeExact(this, (short) 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;S)C", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (char) v, (char) c.invokeExact(this, (short) 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("(S)S", null));
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;S)C", null);
    try {
        c = cast(s, mt);
        if (explicit) {
            try {
                compare(s, mt, (char) v, (char) c.invokeExact(this, (short) 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;S)S", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (short) v, (short) c.invokeExact(this, (short) 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;)S", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (short) v, (short) 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;)S", null);
    try {
        c = cast(s, mt);
        try {
            compare(s, mt, (short) v, (short) c.invokeExact(this, (Object) o));
        } catch (Throwable t) {
            exceptionDuringInvoke(s, mt, t);
        }
    } catch (Throwable t) {
        exceptionDuringCast(s, mt, t);
    }
    /* test boxing */
    mt = MethodType.fromMethodDescriptorString("(Lcom/ibm/j9/jsr292/AsTypeTest;S)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, (short) v, ((Short) (Object) c.invokeExact(this, (short) v)).shortValue());
        } 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, (short) v, ((Short) (Object) c.invokeExact(this, (short) v)).shortValue());
        } 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);
    }
}
Also used : MethodType(java.lang.invoke.MethodType) WrongMethodTypeException(java.lang.invoke.WrongMethodTypeException) MethodHandle(java.lang.invoke.MethodHandle)

Example 10 with WrongMethodTypeException

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

the class ConstantCallSiteTest method testTypeMismatch_TargetHookConstructor.

/**
 * Negative test for protected ConstantCallSite(MethodType targetType,MethodHandle createTargetHook).
 * There is a mismatch between the MT passed in and the MH.type() returned by the hook.
 * A subclass of ConstantCallSite is used to invoke the protected constructor
 * @throws Throwable
 */
@Test(groups = { "level.extended" })
public void testTypeMismatch_TargetHookConstructor() throws Throwable {
    MethodType targetType = MethodType.methodType(String.class);
    MethodHandle hook = MethodHandles.lookup().findStatic(ConstantCallSiteTest.class, "createTargetHook", MethodType.methodType(MethodHandle.class, ConstantCallSite.class));
    boolean wmtHit = false;
    try {
        MyConstantCallSite myCcs = new MyConstantCallSite(targetType, hook);
    } catch (WrongMethodTypeException e) {
        wmtHit = true;
    }
    AssertJUnit.assertTrue(wmtHit);
}
Also used : MethodType(java.lang.invoke.MethodType) ConstantCallSite(java.lang.invoke.ConstantCallSite) WrongMethodTypeException(java.lang.invoke.WrongMethodTypeException) MethodHandle(java.lang.invoke.MethodHandle) Test(org.testng.annotations.Test)

Aggregations

MethodHandle (java.lang.invoke.MethodHandle)18 WrongMethodTypeException (java.lang.invoke.WrongMethodTypeException)18 MethodType (java.lang.invoke.MethodType)10 Test (org.testng.annotations.Test)6 ConstantCallSite (java.lang.invoke.ConstantCallSite)2 MutableCallSite (java.lang.invoke.MutableCallSite)1 SwitchPoint (java.lang.invoke.SwitchPoint)1 VolatileCallSite (java.lang.invoke.VolatileCallSite)1 Test (org.junit.Test)1