1 package test.perf.test1; 2 3 import java.lang.reflect.*; 4 5 import test.perf.AbstractTest; 6 import test.perf.Foo; 7 8 13 public class CachingReflectionTest extends AbstractTest { 14 private Method m; 15 private Object [] args = new Object [0]; 16 17 public void init() { 18 Foo.static_method(); 20 try { 21 m = getMethod(); 22 } 23 catch(Exception e) { 24 System.out.println("ERROR: " + e); 25 } 26 } 27 28 public void test(int lCount) throws Exception { 29 for (int i = 0; i < lCount; i++) { 30 m.invoke(null, args); 31 } 32 } 33 34 35 private Method getMethod() throws Exception { 36 Class c = Foo.class; 37 Method m = c.getDeclaredMethod("static_method", new Class [0]); 38 39 return m; 40 } 41 } 42 | Popular Tags |