Search in sources :

Example 1 with WrongMethodTypeException

use of java.lang.invoke.WrongMethodTypeException in project jdk8u_jdk by JetBrains.

the class BigArityTest method testArities.

private void testArities(Class<? extends Object[]> cls, int minArity, int maxArity, int iterations) throws Throwable {
    boolean verbose = (cls == Object[].class);
    for (int arity = minArity; arity <= maxArity; arity++) {
        if (verbose)
            System.out.println("arity=" + arity);
        MethodHandle mh = MH_hashArguments(cls, arity);
        MethodHandle mh_VA = mh.asSpreader(cls, arity);
        assert (mh_VA.type().parameterType(0) == cls);
        testArities(cls, arity, iterations, verbose, mh, mh_VA);
        // mh_CA will collect arguments of a particular type and pass them to mh_VA
        MethodHandle mh_CA = mh_VA.asCollector(cls, arity);
        MethodHandle mh_VA2 = mh_CA.asSpreader(cls, arity);
        assert (mh_CA.type().equals(mh.type()));
        assert (mh_VA2.type().equals(mh_VA.type()));
        if (cls != Object[].class) {
            try {
                mh_VA2.invokeWithArguments(new Object[arity]);
                throw new AssertionError("should not reach");
            } catch (ClassCastException | WrongMethodTypeException ex) {
            }
        }
        int iterations_VA = iterations / 100;
        testArities(cls, arity, iterations_VA, false, mh_CA, mh_VA2);
    }
}
Also used : WrongMethodTypeException(java.lang.invoke.WrongMethodTypeException) MethodHandle(java.lang.invoke.MethodHandle)

Example 2 with WrongMethodTypeException

use of java.lang.invoke.WrongMethodTypeException in project jdk8u_jdk by JetBrains.

the class BigArityTest method testBoundaryValues.

@Test
public void testBoundaryValues() throws Throwable {
    for (int badArity : new int[] { -1, MAX_JVM_ARITY + 1, MAX_JVM_ARITY }) {
        try {
            MethodHandle badmh = MH_hashArguments(badArity);
            throw new AssertionError("should not be able to build a 255-arity MH: " + badmh);
        } catch (IllegalArgumentException | WrongMethodTypeException ex) {
            System.out.println("OK: " + ex);
        }
    }
    // mh.invoke(arg*[N])
    final int MAX_MH_ARITY = MAX_JVM_ARITY - 1;
    // inv.invoke(mh, arg*[N])
    final int MAX_INVOKER_ARITY = MAX_MH_ARITY - 1;
    for (int arity : new int[] { 0, 1, MAX_MH_ARITY - 2, MAX_MH_ARITY - 1, MAX_MH_ARITY }) {
        MethodHandle mh = MH_hashArguments(arity);
        if (arity < MAX_INVOKER_ARITY) {
            MethodHandle ximh = MethodHandles.exactInvoker(mh.type());
            MethodHandle gimh = MethodHandles.invoker(mh.type());
            MethodHandle simh = MethodHandles.spreadInvoker(mh.type(), 0);
            if (arity != 0) {
                simh = MethodHandles.spreadInvoker(mh.type(), 1);
            } else {
                try {
                    simh = MethodHandles.spreadInvoker(mh.type(), 1);
                    assert (false) : arity;
                } catch (IllegalArgumentException ex) {
                    System.out.println("OK: " + ex);
                }
            }
            if (arity != 0) {
                simh = MethodHandles.spreadInvoker(mh.type(), arity - 1);
            } else {
                try {
                    simh = MethodHandles.spreadInvoker(mh.type(), arity - 1);
                    assert (false) : arity;
                } catch (IllegalArgumentException ex) {
                    System.out.println("OK: " + ex);
                }
            }
            simh = MethodHandles.spreadInvoker(mh.type(), arity);
        }
    }
}
Also used : WrongMethodTypeException(java.lang.invoke.WrongMethodTypeException) MethodHandle(java.lang.invoke.MethodHandle) Test(org.junit.Test)

Example 3 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 = new Integer(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 4 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 = new Double(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 5 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 = new Short(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)

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