19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 * |
22 * |
23 */ |
23 */ |
|
24 |
24 package p; |
25 package p; |
25 |
26 |
26 import java.lang.reflect.InvocationTargetException; |
27 import java.lang.reflect.InvocationTargetException; |
27 import java.lang.reflect.Method; |
28 import java.lang.reflect.Method; |
28 |
29 |
29 /** |
30 /** |
30 * Invokes I.m using reflection. |
31 * Invokes I.m using reflection. |
31 */ |
32 */ |
32 public class Treflect { |
33 public class Treflect { |
33 |
34 |
34 public static int test(p.I ii) throws Throwable { |
35 public static int test(I ii) throws Throwable { |
35 int accum = 0; |
36 int accum = 0; |
36 Method m = p.I.class.getMethod("m"); |
37 Method m = I.class.getMethod("m"); |
37 try { |
38 try { |
38 for (int j = 0; j < 100000; j++) { |
39 for (int j = 0; j < 100000; j++) { |
39 Object o = m.invoke(ii); |
40 Object o = m.invoke(ii); |
40 accum += ((Integer) o).intValue(); |
41 accum += ((Integer) o).intValue(); |
41 } |
42 } |
43 throw ite.getCause(); |
44 throw ite.getCause(); |
44 } |
45 } |
45 return accum; |
46 return accum; |
46 } |
47 } |
47 |
48 |
48 public static int test(p.I ii, byte b, char c, short s, int i, long l, |
49 public static int test(I ii, byte b, char c, short s, int i, long l, |
49 Object o1, Object o2, Object o3, Object o4, Object o5, Object o6) |
50 Object o1, Object o2, Object o3, Object o4, Object o5, Object o6) |
50 throws Throwable { |
51 throws Throwable { |
51 Method m = p.I.class.getMethod("m", Byte.TYPE, Character.TYPE, |
52 Method m = I.class.getMethod("m", Byte.TYPE, Character.TYPE, |
52 Short.TYPE, Integer.TYPE, Long.TYPE, |
53 Short.TYPE, Integer.TYPE, Long.TYPE, |
53 Object.class, Object.class, Object.class, |
54 Object.class, Object.class, Object.class, |
54 Object.class, Object.class, Object.class); |
55 Object.class, Object.class, Object.class); |
55 int accum = 0; |
56 int accum = 0; |
56 try { |
57 try { |