593 break;
594 }
595 return result;
596 }
597
598 private void returnVoid() {
599 }
600
601 private Kind(int value) {
602 this.value = value;
603 }
604 }
605
606 /**
607 * Routine used to obtain a randomly generated method type.
608 *
609 * @param arity Arity of returned method type.
610 * @return MethodType generated randomly.
611 */
612 private static MethodType randomMethodTypeGenerator(int arity) {
613 final Class<?>[] CLASSES = {
614 Object.class,
615 int.class,
616 boolean.class,
617 byte.class,
618 short.class,
619 char.class,
620 long.class,
621 float.class,
622 double.class
623 };
624 if (arity > Helper.MAX_ARITY) {
625 throw new IllegalArgumentException(
626 String.format("Arity should not exceed %d!", Helper.MAX_ARITY));
627 }
628 List<Class<?>> list = Helper.randomClasses(CLASSES, arity);
629 list = Helper.getParams(list, false, arity);
630 int i = Helper.RNG.nextInt(CLASSES.length + 1);
631 Class<?> rtype = i == CLASSES.length ? void.class : CLASSES[i];
632 return MethodType.methodType(rtype, list);
633 }
634
635 /**
636 * Routine used to obtain a method handles of a given type an kind (return
637 * value).
638 *
639 * @param returnType Type of MH return value.
640 * @param argTypes Types of MH args.
641 * @param kind Defines whether the obtained MH returns "1" or "2".
642 * @return Method handle of the given type.
643 * @throws NoSuchMethodException
644 * @throws IllegalAccessException
645 */
646 private static MethodHandle methodHandleGenerator(Class<?> returnType,
647 List<Class<?>> argTypes, TestMethods.Kind kind)
648 throws NoSuchMethodException, IllegalAccessException {
649 MethodHandle result;
650 result = kind.getBasicMH(returnType);
651 return Helper.addTrailingArgs(result, argTypes.size(), argTypes);
652 }
|
593 break;
594 }
595 return result;
596 }
597
598 private void returnVoid() {
599 }
600
601 private Kind(int value) {
602 this.value = value;
603 }
604 }
605
606 /**
607 * Routine used to obtain a randomly generated method type.
608 *
609 * @param arity Arity of returned method type.
610 * @return MethodType generated randomly.
611 */
612 private static MethodType randomMethodTypeGenerator(int arity) {
613 return Helper.randomMethodTypeGenerator(arity);
614 }
615
616 /**
617 * Routine used to obtain a method handles of a given type an kind (return
618 * value).
619 *
620 * @param returnType Type of MH return value.
621 * @param argTypes Types of MH args.
622 * @param kind Defines whether the obtained MH returns "1" or "2".
623 * @return Method handle of the given type.
624 * @throws NoSuchMethodException
625 * @throws IllegalAccessException
626 */
627 private static MethodHandle methodHandleGenerator(Class<?> returnType,
628 List<Class<?>> argTypes, TestMethods.Kind kind)
629 throws NoSuchMethodException, IllegalAccessException {
630 MethodHandle result;
631 result = kind.getBasicMH(returnType);
632 return Helper.addTrailingArgs(result, argTypes.size(), argTypes);
633 }
|