Path: blob/master/test/hotspot/jtreg/compiler/jsr292/methodHandleExceptions/p/Treflect.java
41161 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package p;2425import java.lang.reflect.InvocationTargetException;26import java.lang.reflect.Method;2728/**29* Invokes I.m using reflection.30*/31public class Treflect {3233public static int test(I ii) throws Throwable {34int accum = 0;35Method m = I.class.getMethod("m");36try {37for (int j = 0; j < 100000; j++) {38Object o = m.invoke(ii);39accum += ((Integer) o).intValue();40}41} catch (InvocationTargetException ite) {42throw ite.getCause();43}44return accum;45}4647public static int test(I ii, byte b, char c, short s, int i, long l,48Object o1, Object o2, Object o3, Object o4, Object o5, Object o6)49throws Throwable {50Method m = I.class.getMethod("m", Byte.TYPE, Character.TYPE,51Short.TYPE, Integer.TYPE, Long.TYPE,52Object.class, Object.class, Object.class,53Object.class, Object.class, Object.class);54int accum = 0;55try {56for (int j = 0; j < 100000; j++) {57Object o = m.invoke(ii, b, c, s, i, l, o1, o2, o3, o4, o5, o6);58accum += ((Integer) o).intValue();59}60} catch (InvocationTargetException ite) {61throw ite.getCause();62}63return accum;64}65}666768