equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
608 * |
608 * |
609 * @param arity Arity of returned method type. |
609 * @param arity Arity of returned method type. |
610 * @return MethodType generated randomly. |
610 * @return MethodType generated randomly. |
611 */ |
611 */ |
612 private static MethodType randomMethodTypeGenerator(int arity) { |
612 private static MethodType randomMethodTypeGenerator(int arity) { |
613 final Class<?>[] CLASSES = { |
613 return Helper.randomMethodTypeGenerator(arity); |
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 } |
614 } |
634 |
615 |
635 /** |
616 /** |
636 * Routine used to obtain a method handles of a given type an kind (return |
617 * Routine used to obtain a method handles of a given type an kind (return |
637 * value). |
618 * value). |