Java Code Examples for com.oracle.testlibrary.jsr292.Helper#randomArgs()
The following examples show how to use
com.oracle.testlibrary.jsr292.Helper#randomArgs() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExplicitCastArgumentsTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Tests that MHs.eCA method works correctly with MHs with multiple arguments. * @throws Throwable */ public static void testMultipleArgs() throws Throwable { int arity = 1 + RNG.nextInt(Helper.MAX_ARITY / 2 - 2); int arityMinus = RNG.nextInt(arity); int arityPlus = arity + RNG.nextInt(Helper.MAX_ARITY / 2 - arity) + 1; MethodType mType = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNew = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNewMinus = Helper.randomMethodTypeGenerator(arityMinus); MethodType mTypeNewPlus = Helper.randomMethodTypeGenerator(arityPlus); Class<?> rType = mType.returnType(); MethodHandle original; if (rType.equals(void.class)) { MethodType mt = MethodType.methodType(void.class); original = MethodHandles.publicLookup() .findStatic(THIS_CLASS, "retVoid", mt); } else { Object rValue = Helper.castToWrapper(1, rType); original = MethodHandles.constant(rType, rValue); } original = Helper.addTrailingArgs(original, arity, mType.parameterList()); MethodHandle target = MethodHandles .explicitCastArguments(original, mTypeNew); Object[] parList = Helper.randomArgs(mTypeNew.parameterList()); for (int i = 0; i < parList.length; i++) { if (parList[i] instanceof String) { parList[i] = null; //getting rid of Stings produced by randomArgs } } target.invokeWithArguments(parList); checkForWrongMethodTypeException(original, mTypeNewMinus); checkForWrongMethodTypeException(original, mTypeNewPlus); }
Example 2
Source File: CatchExceptionTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private void runTest() { Helper.clear(); Object[] args = Helper.randomArgs( argsCount, thrower.type().parameterArray()); Object arg0 = Helper.MISSING_ARG; Object arg1 = testCase.thrown; if (argsCount > 0) { arg0 = args[0]; } if (argsCount > 1) { args[1] = arg1; } Asserts.assertEQ(nargs, thrower.type().parameterCount()); if (argsCount < nargs) { Object[] appendArgs = {arg0, arg1}; appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs); thrower = MethodHandles.insertArguments( thrower, argsCount, appendArgs); } Asserts.assertEQ(argsCount, thrower.type().parameterCount()); MethodHandle target = MethodHandles.catchException( testCase.filter(thrower), testCase.throwableClass, testCase.filter(catcher)); Asserts.assertEQ(thrower.type(), target.type()); Asserts.assertEQ(argsCount, target.type().parameterCount()); Object returned; try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { testCase.assertCatch(ex); returned = ex; } testCase.assertReturn(returned, arg0, arg1, dropped, args); }
Example 3
Source File: CatchExceptionTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void runTest() { Helper.clear(); Object[] args = Helper.randomArgs( argsCount, thrower.type().parameterArray()); Object arg0 = Helper.MISSING_ARG; Object arg1 = testCase.thrown; if (argsCount > 0) { arg0 = args[0]; } if (argsCount > 1) { args[1] = arg1; } Asserts.assertEQ(nargs, thrower.type().parameterCount()); if (argsCount < nargs) { Object[] appendArgs = {arg0, arg1}; appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs); thrower = MethodHandles.insertArguments( thrower, argsCount, appendArgs); } Asserts.assertEQ(argsCount, thrower.type().parameterCount()); MethodHandle target = MethodHandles.catchException( testCase.filter(thrower), testCase.throwableClass, testCase.filter(catcher)); Asserts.assertEQ(thrower.type(), target.type()); Asserts.assertEQ(argsCount, target.type().parameterCount()); Object returned; try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { testCase.assertCatch(ex); returned = ex; } testCase.assertReturn(returned, arg0, arg1, dropped, args); }
Example 4
Source File: ExplicitCastArgumentsTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Tests that MHs.eCA method works correctly with MHs with multiple arguments. * @throws Throwable */ public static void testMultipleArgs() throws Throwable { int arity = 1 + RNG.nextInt(Helper.MAX_ARITY / 2 - 2); int arityMinus = RNG.nextInt(arity); int arityPlus = arity + RNG.nextInt(Helper.MAX_ARITY / 2 - arity) + 1; MethodType mType = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNew = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNewMinus = Helper.randomMethodTypeGenerator(arityMinus); MethodType mTypeNewPlus = Helper.randomMethodTypeGenerator(arityPlus); Class<?> rType = mType.returnType(); MethodHandle original; if (rType.equals(void.class)) { MethodType mt = MethodType.methodType(void.class); original = MethodHandles.publicLookup() .findStatic(THIS_CLASS, "retVoid", mt); } else { Object rValue = Helper.castToWrapper(1, rType); original = MethodHandles.constant(rType, rValue); } original = Helper.addTrailingArgs(original, arity, mType.parameterList()); MethodHandle target = MethodHandles .explicitCastArguments(original, mTypeNew); Object[] parList = Helper.randomArgs(mTypeNew.parameterList()); for (int i = 0; i < parList.length; i++) { if (parList[i] instanceof String) { parList[i] = null; //getting rid of Stings produced by randomArgs } } target.invokeWithArguments(parList); checkForWrongMethodTypeException(original, mTypeNewMinus); checkForWrongMethodTypeException(original, mTypeNewPlus); }
Example 5
Source File: ExplicitCastArgumentsTest.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Tests that MHs.eCA method works correctly with MHs with multiple arguments. * @throws Throwable */ public static void testMultipleArgs() throws Throwable { int arity = 1 + RNG.nextInt(Helper.MAX_ARITY / 2 - 2); int arityMinus = RNG.nextInt(arity); int arityPlus = arity + RNG.nextInt(Helper.MAX_ARITY / 2 - arity) + 1; MethodType mType = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNew = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNewMinus = Helper.randomMethodTypeGenerator(arityMinus); MethodType mTypeNewPlus = Helper.randomMethodTypeGenerator(arityPlus); Class<?> rType = mType.returnType(); MethodHandle original; if (rType.equals(void.class)) { MethodType mt = MethodType.methodType(void.class); original = MethodHandles.publicLookup() .findStatic(THIS_CLASS, "retVoid", mt); } else { Object rValue = Helper.castToWrapper(1, rType); original = MethodHandles.constant(rType, rValue); } original = Helper.addTrailingArgs(original, arity, mType.parameterList()); MethodHandle target = MethodHandles .explicitCastArguments(original, mTypeNew); Object[] parList = Helper.randomArgs(mTypeNew.parameterList()); for (int i = 0; i < parList.length; i++) { if (parList[i] instanceof String) { parList[i] = null; //getting rid of Stings produced by randomArgs } } target.invokeWithArguments(parList); checkForWrongMethodTypeException(original, mTypeNewMinus); checkForWrongMethodTypeException(original, mTypeNewPlus); }
Example 6
Source File: ExplicitCastArgumentsTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Tests that MHs.eCA method works correctly with MHs with multiple arguments. * @throws Throwable */ public static void testMultipleArgs() throws Throwable { int arity = 1 + RNG.nextInt(Helper.MAX_ARITY / 2 - 2); int arityMinus = RNG.nextInt(arity); int arityPlus = arity + RNG.nextInt(Helper.MAX_ARITY / 2 - arity) + 1; MethodType mType = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNew = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNewMinus = Helper.randomMethodTypeGenerator(arityMinus); MethodType mTypeNewPlus = Helper.randomMethodTypeGenerator(arityPlus); Class<?> rType = mType.returnType(); MethodHandle original; if (rType.equals(void.class)) { MethodType mt = MethodType.methodType(void.class); original = MethodHandles.publicLookup() .findStatic(THIS_CLASS, "retVoid", mt); } else { Object rValue = Helper.castToWrapper(1, rType); original = MethodHandles.constant(rType, rValue); } original = Helper.addTrailingArgs(original, arity, mType.parameterList()); MethodHandle target = MethodHandles .explicitCastArguments(original, mTypeNew); Object[] parList = Helper.randomArgs(mTypeNew.parameterList()); for (int i = 0; i < parList.length; i++) { if (parList[i] instanceof String) { parList[i] = null; //getting rid of Stings produced by randomArgs } } target.invokeWithArguments(parList); checkForWrongMethodTypeException(original, mTypeNewMinus); checkForWrongMethodTypeException(original, mTypeNewPlus); }
Example 7
Source File: ExplicitCastArgumentsTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Tests that MHs.eCA method works correctly with MHs with multiple arguments. * @throws Throwable */ public static void testMultipleArgs() throws Throwable { int arity = 1 + RNG.nextInt(Helper.MAX_ARITY / 2 - 2); int arityMinus = RNG.nextInt(arity); int arityPlus = arity + RNG.nextInt(Helper.MAX_ARITY / 2 - arity) + 1; MethodType mType = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNew = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNewMinus = Helper.randomMethodTypeGenerator(arityMinus); MethodType mTypeNewPlus = Helper.randomMethodTypeGenerator(arityPlus); Class<?> rType = mType.returnType(); MethodHandle original; if (rType.equals(void.class)) { MethodType mt = MethodType.methodType(void.class); original = MethodHandles.publicLookup() .findStatic(THIS_CLASS, "retVoid", mt); } else { Object rValue = Helper.castToWrapper(1, rType); original = MethodHandles.constant(rType, rValue); } original = Helper.addTrailingArgs(original, arity, mType.parameterList()); MethodHandle target = MethodHandles .explicitCastArguments(original, mTypeNew); Object[] parList = Helper.randomArgs(mTypeNew.parameterList()); for (int i = 0; i < parList.length; i++) { if (parList[i] instanceof String) { parList[i] = null; //getting rid of Stings produced by randomArgs } } target.invokeWithArguments(parList); checkForWrongMethodTypeException(original, mTypeNewMinus); checkForWrongMethodTypeException(original, mTypeNewPlus); }
Example 8
Source File: ExplicitCastArgumentsTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Tests that MHs.eCA method works correctly with MHs with multiple arguments. * @throws Throwable */ public static void testMultipleArgs() throws Throwable { int arity = 1 + RNG.nextInt(Helper.MAX_ARITY / 2 - 2); int arityMinus = RNG.nextInt(arity); int arityPlus = arity + RNG.nextInt(Helper.MAX_ARITY / 2 - arity) + 1; MethodType mType = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNew = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNewMinus = Helper.randomMethodTypeGenerator(arityMinus); MethodType mTypeNewPlus = Helper.randomMethodTypeGenerator(arityPlus); Class<?> rType = mType.returnType(); MethodHandle original; if (rType.equals(void.class)) { MethodType mt = MethodType.methodType(void.class); original = MethodHandles.publicLookup() .findStatic(THIS_CLASS, "retVoid", mt); } else { Object rValue = Helper.castToWrapper(1, rType); original = MethodHandles.constant(rType, rValue); } original = Helper.addTrailingArgs(original, arity, mType.parameterList()); MethodHandle target = MethodHandles .explicitCastArguments(original, mTypeNew); Object[] parList = Helper.randomArgs(mTypeNew.parameterList()); for (int i = 0; i < parList.length; i++) { if (parList[i] instanceof String) { parList[i] = null; //getting rid of Stings produced by randomArgs } } target.invokeWithArguments(parList); checkForWrongMethodTypeException(original, mTypeNewMinus); checkForWrongMethodTypeException(original, mTypeNewPlus); }
Example 9
Source File: ExplicitCastArgumentsTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Tests that MHs.eCA method works correctly with MHs with multiple arguments. * @throws Throwable */ public static void testMultipleArgs() throws Throwable { int arity = 1 + RNG.nextInt(Helper.MAX_ARITY / 2 - 2); int arityMinus = RNG.nextInt(arity); int arityPlus = arity + RNG.nextInt(Helper.MAX_ARITY / 2 - arity) + 1; MethodType mType = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNew = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNewMinus = Helper.randomMethodTypeGenerator(arityMinus); MethodType mTypeNewPlus = Helper.randomMethodTypeGenerator(arityPlus); Class<?> rType = mType.returnType(); MethodHandle original; if (rType.equals(void.class)) { MethodType mt = MethodType.methodType(void.class); original = MethodHandles.publicLookup() .findStatic(THIS_CLASS, "retVoid", mt); } else { Object rValue = Helper.castToWrapper(1, rType); original = MethodHandles.constant(rType, rValue); } original = Helper.addTrailingArgs(original, arity, mType.parameterList()); MethodHandle target = MethodHandles .explicitCastArguments(original, mTypeNew); Object[] parList = Helper.randomArgs(mTypeNew.parameterList()); for (int i = 0; i < parList.length; i++) { if (parList[i] instanceof String) { parList[i] = null; //getting rid of Stings produced by randomArgs } } target.invokeWithArguments(parList); checkForWrongMethodTypeException(original, mTypeNewMinus); checkForWrongMethodTypeException(original, mTypeNewPlus); }
Example 10
Source File: ExplicitCastArgumentsTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Tests that MHs.eCA method works correctly with MHs with multiple arguments. * @throws Throwable */ public static void testMultipleArgs() throws Throwable { int arity = 1 + RNG.nextInt(Helper.MAX_ARITY / 2 - 2); int arityMinus = RNG.nextInt(arity); int arityPlus = arity + RNG.nextInt(Helper.MAX_ARITY / 2 - arity) + 1; MethodType mType = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNew = Helper.randomMethodTypeGenerator(arity); MethodType mTypeNewMinus = Helper.randomMethodTypeGenerator(arityMinus); MethodType mTypeNewPlus = Helper.randomMethodTypeGenerator(arityPlus); Class<?> rType = mType.returnType(); MethodHandle original; if (rType.equals(void.class)) { MethodType mt = MethodType.methodType(void.class); original = MethodHandles.publicLookup() .findStatic(THIS_CLASS, "retVoid", mt); } else { Object rValue = Helper.castToWrapper(1, rType); original = MethodHandles.constant(rType, rValue); } original = Helper.addTrailingArgs(original, arity, mType.parameterList()); MethodHandle target = MethodHandles .explicitCastArguments(original, mTypeNew); Object[] parList = Helper.randomArgs(mTypeNew.parameterList()); for (int i = 0; i < parList.length; i++) { if (parList[i] instanceof String) { parList[i] = null; //getting rid of Stings produced by randomArgs } } target.invokeWithArguments(parList); checkForWrongMethodTypeException(original, mTypeNewMinus); checkForWrongMethodTypeException(original, mTypeNewPlus); }
Example 11
Source File: CatchExceptionTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private void runTest() { if (Helper.IS_VERBOSE) { System.out.printf("CatchException(%s, isVararg=%b argsCount=%d " + "dropped=%d)%n", testCase, thrower.isVarargsCollector(), argsCount, dropped); } Helper.clear(); Object[] args = Helper.randomArgs( argsCount, thrower.type().parameterArray()); Object arg0 = Helper.MISSING_ARG; Object arg1 = testCase.thrown; if (argsCount > 0) { arg0 = args[0]; } if (argsCount > 1) { args[1] = arg1; } Asserts.assertEQ(nargs, thrower.type().parameterCount()); if (argsCount < nargs) { Object[] appendArgs = {arg0, arg1}; appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs); thrower = MethodHandles.insertArguments( thrower, argsCount, appendArgs); } Asserts.assertEQ(argsCount, thrower.type().parameterCount()); MethodHandle target = MethodHandles.catchException( testCase.filter(thrower), testCase.throwableClass, testCase.filter(catcher)); Asserts.assertEQ(thrower.type(), target.type()); Asserts.assertEQ(argsCount, target.type().parameterCount()); Object returned; try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { if (CodeCacheOverflowProcessor.isThrowableCausedByVME(ex)) { // This error will be treated by CodeCacheOverflowProcessor // to prevent the test from failing because of code cache overflow. throw new Error(ex); } testCase.assertCatch(ex); returned = ex; } testCase.assertReturn(returned, arg0, arg1, dropped, args); }
Example 12
Source File: CatchExceptionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private void runTest() { if (Helper.IS_VERBOSE) { System.out.printf("CatchException(%s, isVararg=%b argsCount=%d " + "dropped=%d)%n", testCase, thrower.isVarargsCollector(), argsCount, dropped); } Helper.clear(); Object[] args = Helper.randomArgs( argsCount, thrower.type().parameterArray()); Object arg0 = Helper.MISSING_ARG; Object arg1 = testCase.thrown; if (argsCount > 0) { arg0 = args[0]; } if (argsCount > 1) { args[1] = arg1; } Asserts.assertEQ(nargs, thrower.type().parameterCount()); if (argsCount < nargs) { Object[] appendArgs = {arg0, arg1}; appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs); thrower = MethodHandles.insertArguments( thrower, argsCount, appendArgs); } Asserts.assertEQ(argsCount, thrower.type().parameterCount()); MethodHandle target = MethodHandles.catchException( testCase.filter(thrower), testCase.throwableClass, testCase.filter(catcher)); Asserts.assertEQ(thrower.type(), target.type()); Asserts.assertEQ(argsCount, target.type().parameterCount()); Object returned; try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { if (CodeCacheOverflowProcessor.isThrowableCausedByVME(ex)) { // This error will be treated by CodeCacheOverflowProcessor // to prevent the test from failing because of code cache overflow. throw new Error(ex); } testCase.assertCatch(ex); returned = ex; } testCase.assertReturn(returned, arg0, arg1, dropped, args); }
Example 13
Source File: CatchExceptionTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private void runTest() { if (Helper.IS_VERBOSE) { System.out.printf("CatchException(%s, isVararg=%b argsCount=%d " + "dropped=%d)%n", testCase, thrower.isVarargsCollector(), argsCount, dropped); } Helper.clear(); Object[] args = Helper.randomArgs( argsCount, thrower.type().parameterArray()); Object arg0 = Helper.MISSING_ARG; Object arg1 = testCase.thrown; if (argsCount > 0) { arg0 = args[0]; } if (argsCount > 1) { args[1] = arg1; } Asserts.assertEQ(nargs, thrower.type().parameterCount()); if (argsCount < nargs) { Object[] appendArgs = {arg0, arg1}; appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs); thrower = MethodHandles.insertArguments( thrower, argsCount, appendArgs); } Asserts.assertEQ(argsCount, thrower.type().parameterCount()); MethodHandle target = MethodHandles.catchException( testCase.filter(thrower), testCase.throwableClass, testCase.filter(catcher)); Asserts.assertEQ(thrower.type(), target.type()); Asserts.assertEQ(argsCount, target.type().parameterCount()); Object returned; try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { if (CodeCacheOverflowProcessor.isThrowableCausedByVME(ex)) { // This error will be treated by CodeCacheOverflowProcessor // to prevent the test from failing because of code cache overflow. throw new Error(ex); } testCase.assertCatch(ex); returned = ex; } testCase.assertReturn(returned, arg0, arg1, dropped, args); }
Example 14
Source File: CatchExceptionTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private void runTest() { if (Helper.IS_VERBOSE) { System.out.printf("CatchException(%s, isVararg=%b argsCount=%d " + "dropped=%d)%n", testCase, thrower.isVarargsCollector(), argsCount, dropped); } Helper.clear(); Object[] args = Helper.randomArgs( argsCount, thrower.type().parameterArray()); Object arg0 = Helper.MISSING_ARG; Object arg1 = testCase.thrown; if (argsCount > 0) { arg0 = args[0]; } if (argsCount > 1) { args[1] = arg1; } Asserts.assertEQ(nargs, thrower.type().parameterCount()); if (argsCount < nargs) { Object[] appendArgs = {arg0, arg1}; appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs); thrower = MethodHandles.insertArguments( thrower, argsCount, appendArgs); } Asserts.assertEQ(argsCount, thrower.type().parameterCount()); MethodHandle target = MethodHandles.catchException( testCase.filter(thrower), testCase.throwableClass, testCase.filter(catcher)); Asserts.assertEQ(thrower.type(), target.type()); Asserts.assertEQ(argsCount, target.type().parameterCount()); Object returned; try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { if (CodeCacheOverflowProcessor.isThrowableCausedByVME(ex)) { // This error will be treated by CodeCacheOverflowProcessor // to prevent the test from failing because of code cache overflow. throw new Error(ex); } testCase.assertCatch(ex); returned = ex; } testCase.assertReturn(returned, arg0, arg1, dropped, args); }
Example 15
Source File: CatchExceptionTest.java From hottub with GNU General Public License v2.0 | 4 votes |
private void runTest() { if (Helper.IS_VERBOSE) { System.out.printf("CatchException(%s, isVararg=%b argsCount=%d " + "dropped=%d)%n", testCase, thrower.isVarargsCollector(), argsCount, dropped); } Helper.clear(); Object[] args = Helper.randomArgs( argsCount, thrower.type().parameterArray()); Object arg0 = Helper.MISSING_ARG; Object arg1 = testCase.thrown; if (argsCount > 0) { arg0 = args[0]; } if (argsCount > 1) { args[1] = arg1; } Asserts.assertEQ(nargs, thrower.type().parameterCount()); if (argsCount < nargs) { Object[] appendArgs = {arg0, arg1}; appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs); thrower = MethodHandles.insertArguments( thrower, argsCount, appendArgs); } Asserts.assertEQ(argsCount, thrower.type().parameterCount()); MethodHandle target = MethodHandles.catchException( testCase.filter(thrower), testCase.throwableClass, testCase.filter(catcher)); Asserts.assertEQ(thrower.type(), target.type()); Asserts.assertEQ(argsCount, target.type().parameterCount()); Object returned; try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { if (CodeCacheOverflowProcessor.isThrowableCausedByVME(ex)) { // This error will be treated by CodeCacheOverflowProcessor // to prevent the test from failing because of code cache overflow. throw new Error(ex); } testCase.assertCatch(ex); returned = ex; } testCase.assertReturn(returned, arg0, arg1, dropped, args); }
Example 16
Source File: CatchExceptionTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private void runTest() { if (Helper.IS_VERBOSE) { System.out.printf("CatchException(%s, isVararg=%b argsCount=%d " + "dropped=%d)%n", testCase, thrower.isVarargsCollector(), argsCount, dropped); } Helper.clear(); Object[] args = Helper.randomArgs( argsCount, thrower.type().parameterArray()); Object arg0 = Helper.MISSING_ARG; Object arg1 = testCase.thrown; if (argsCount > 0) { arg0 = args[0]; } if (argsCount > 1) { args[1] = arg1; } Asserts.assertEQ(nargs, thrower.type().parameterCount()); if (argsCount < nargs) { Object[] appendArgs = {arg0, arg1}; appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs); thrower = MethodHandles.insertArguments( thrower, argsCount, appendArgs); } Asserts.assertEQ(argsCount, thrower.type().parameterCount()); MethodHandle target = MethodHandles.catchException( testCase.filter(thrower), testCase.throwableClass, testCase.filter(catcher)); Asserts.assertEQ(thrower.type(), target.type()); Asserts.assertEQ(argsCount, target.type().parameterCount()); Object returned; try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { testCase.assertCatch(ex); returned = ex; } testCase.assertReturn(returned, arg0, arg1, dropped, args); }
Example 17
Source File: CatchExceptionTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private void runTest() { if (Helper.IS_VERBOSE) { System.out.printf("CatchException(%s, isVararg=%b argsCount=%d " + "dropped=%d)%n", testCase, thrower.isVarargsCollector(), argsCount, dropped); } Helper.clear(); Object[] args = Helper.randomArgs( argsCount, thrower.type().parameterArray()); Object arg0 = Helper.MISSING_ARG; Object arg1 = testCase.thrown; if (argsCount > 0) { arg0 = args[0]; } if (argsCount > 1) { args[1] = arg1; } Asserts.assertEQ(nargs, thrower.type().parameterCount()); if (argsCount < nargs) { Object[] appendArgs = {arg0, arg1}; appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs); thrower = MethodHandles.insertArguments( thrower, argsCount, appendArgs); } Asserts.assertEQ(argsCount, thrower.type().parameterCount()); MethodHandle target = MethodHandles.catchException( testCase.filter(thrower), testCase.throwableClass, testCase.filter(catcher)); Asserts.assertEQ(thrower.type(), target.type()); Asserts.assertEQ(argsCount, target.type().parameterCount()); Object returned; try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { if (CodeCacheOverflowProcessor.isThrowableCausedByVME(ex)) { // This error will be treated by CodeCacheOverflowProcessor // to prevent the test from failing because of code cache overflow. throw new Error(ex); } testCase.assertCatch(ex); returned = ex; } testCase.assertReturn(returned, arg0, arg1, dropped, args); }
Example 18
Source File: CatchExceptionTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private void runTest() { if (Helper.IS_VERBOSE) { System.out.printf("CatchException(%s, isVararg=%b argsCount=%d " + "dropped=%d)%n", testCase, thrower.isVarargsCollector(), argsCount, dropped); } Helper.clear(); Object[] args = Helper.randomArgs( argsCount, thrower.type().parameterArray()); Object arg0 = Helper.MISSING_ARG; Object arg1 = testCase.thrown; if (argsCount > 0) { arg0 = args[0]; } if (argsCount > 1) { args[1] = arg1; } Asserts.assertEQ(nargs, thrower.type().parameterCount()); if (argsCount < nargs) { Object[] appendArgs = {arg0, arg1}; appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs); thrower = MethodHandles.insertArguments( thrower, argsCount, appendArgs); } Asserts.assertEQ(argsCount, thrower.type().parameterCount()); MethodHandle target = MethodHandles.catchException( testCase.filter(thrower), testCase.throwableClass, testCase.filter(catcher)); Asserts.assertEQ(thrower.type(), target.type()); Asserts.assertEQ(argsCount, target.type().parameterCount()); Object returned; try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { if (CodeCacheOverflowProcessor.isThrowableCausedByVME(ex)) { // This error will be treated by CodeCacheOverflowProcessor // to prevent the test from failing because of code cache overflow. throw new Error(ex); } testCase.assertCatch(ex); returned = ex; } testCase.assertReturn(returned, arg0, arg1, dropped, args); }
Example 19
Source File: CatchExceptionTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private void runTest() { if (Helper.IS_VERBOSE) { System.out.printf("CatchException(%s, isVararg=%b argsCount=%d " + "dropped=%d)%n", testCase, thrower.isVarargsCollector(), argsCount, dropped); } Helper.clear(); Object[] args = Helper.randomArgs( argsCount, thrower.type().parameterArray()); Object arg0 = Helper.MISSING_ARG; Object arg1 = testCase.thrown; if (argsCount > 0) { arg0 = args[0]; } if (argsCount > 1) { args[1] = arg1; } Asserts.assertEQ(nargs, thrower.type().parameterCount()); if (argsCount < nargs) { Object[] appendArgs = {arg0, arg1}; appendArgs = Arrays.copyOfRange(appendArgs, argsCount, nargs); thrower = MethodHandles.insertArguments( thrower, argsCount, appendArgs); } Asserts.assertEQ(argsCount, thrower.type().parameterCount()); MethodHandle target = MethodHandles.catchException( testCase.filter(thrower), testCase.throwableClass, testCase.filter(catcher)); Asserts.assertEQ(thrower.type(), target.type()); Asserts.assertEQ(argsCount, target.type().parameterCount()); Object returned; try { returned = target.invokeWithArguments(args); } catch (Throwable ex) { if (CodeCacheOverflowProcessor.isThrowableCausedByVME(ex)) { // This error will be treated by CodeCacheOverflowProcessor // to prevent the test from failing because of code cache overflow. throw new Error(ex); } testCase.assertCatch(ex); returned = ex; } testCase.assertReturn(returned, arg0, arg1, dropped, args); }