(Object obj, String name, Object... argsTypesAndReturnType)
| 679 | } |
| 680 | |
| 681 | public static Object invokeVirtual(Object obj, String name, Object... argsTypesAndReturnType) |
| 682 | throws ReflectiveOperationException { |
| 683 | Class clazz = obj.getClass(); |
| 684 | int argc = argsTypesAndReturnType.length / 2; |
| 685 | Class[] argt = new Class[argc]; |
| 686 | Object[] argv = new Object[argc]; |
| 687 | Class returnType = null; |
| 688 | if (argc * 2 + 1 == argsTypesAndReturnType.length) { |
| 689 | returnType = (Class) argsTypesAndReturnType[argsTypesAndReturnType.length - 1]; |
| 690 | } |
| 691 | int i, ii; |
| 692 | Method[] m; |
| 693 | Method method = null; |
| 694 | Class[] _argt; |
| 695 | for (i = 0; i < argc; i++) { |
| 696 | argt[i] = (Class) argsTypesAndReturnType[argc + i]; |
| 697 | argv[i] = argsTypesAndReturnType[i]; |
| 698 | } |
| 699 | loop_main: |
| 700 | do { |
| 701 | m = clazz.getDeclaredMethods(); |
| 702 | loop: |
| 703 | for (i = 0; i < m.length; i++) { |
| 704 | if (m[i].getName().equals(name)) { |
| 705 | _argt = m[i].getParameterTypes(); |
| 706 | if (_argt.length == argt.length) { |
| 707 | for (ii = 0; ii < argt.length; ii++) { |
| 708 | if (!argt[ii].equals(_argt[ii])) { |
| 709 | continue loop; |
| 710 | } |
| 711 | } |
| 712 | if (returnType != null && !returnType.equals(m[i].getReturnType())) { |
| 713 | continue; |
| 714 | } |
| 715 | method = m[i]; |
| 716 | break loop_main; |
| 717 | } |
| 718 | } |
| 719 | } |
| 720 | } while (!Object.class.equals(clazz = clazz.getSuperclass())); |
| 721 | if (method == null) { |
| 722 | throw new NoSuchMethodException( |
| 723 | name + paramsTypesToString(argt) + " in " + obj.getClass().getName()); |
| 724 | } |
| 725 | method.setAccessible(true); |
| 726 | return method.invoke(obj, argv); |
| 727 | } |
| 728 | |
| 729 | public static Object invokeVirtualOriginal(Object obj, String name, Object... argsTypesAndReturnType) |
| 730 | throws ReflectiveOperationException { |
no test coverage detected