KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > perf > test1 > ReflectionTest


1 package test.perf.test1;
2
3 import java.lang.reflect.*;
4
5 import test.perf.AbstractTest;
6 import test.perf.Foo;
7
8 /**
9  * Class tc1.
10  *
11  * @author Mika Riekkinen
12  */

13 public class ReflectionTest extends AbstractTest {
14     public void init() {
15         // Make one call to load Foo into JVM
16
Foo.static_method();
17     }
18
19     public void test(int lCount) throws Exception JavaDoc {
20         for (int i = 0; i < lCount; i++) {
21             Method m = getMethod();
22             m.invoke(null, new Object JavaDoc[0]);
23         }
24     }
25
26
27     private Method getMethod() throws Exception JavaDoc {
28         Class JavaDoc c = Foo.class;
29         Method m = c.getDeclaredMethod("static_method", new Class JavaDoc[0]);
30
31         return m;
32     }
33 }
34
Popular Tags