1 16 package net.sf.cglib.reflect; 17 18 import java.lang.reflect.InvocationTargetException ; 19 import java.lang.reflect.Method ; 20 21 public class FastMethod extends FastMember 22 { 23 FastMethod(FastClass fc, Method method) { 24 super(fc, method, helper(fc, method)); 25 } 26 27 private static int helper(FastClass fc, Method method) { 28 int index = fc.getIndex(method.getName(), method.getParameterTypes()); 29 if (index < 0) { 30 Class [] types = method.getParameterTypes(); 31 System.err.println("hash=" + method.getName().hashCode() + " size=" + types.length); 32 for (int i = 0; i < types.length; i++) { 33 System.err.println(" types[" + i + "]=" + types[i].getName()); 34 } 35 throw new IllegalArgumentException ("Cannot find method " + method); 36 } 37 return index; 38 } 39 40 public Class getReturnType() { 41 return ((Method )member).getReturnType(); 42 } 43 44 public Class [] getParameterTypes() { 45 return ((Method )member).getParameterTypes(); 46 } 47 48 public Class [] getExceptionTypes() { 49 return ((Method )member).getExceptionTypes(); 50 } 51 52 public Object invoke(Object obj, Object [] args) throws InvocationTargetException { 53 return fc.invoke(index, obj, args); 54 } 55 56 public Method getJavaMethod() { 57 return (Method )member; 58 } 59 } 60 | Popular Tags |