1 import com.zkn.newlearn.gof.proxyhandler.PersonInter; 2 import java.lang.reflect.InvocationHandler; 3 import java.lang.reflect.Method; 4 import java.lang.reflect.Proxy; 5 import java.lang.reflect.UndeclaredThrowableException; 6 7 public final class Proxy4 extends Proxy 8 implements PersonInter 9 { 10 private static Method m1; 11 private static Method m2; 12 private static Method m3; 13 private static Method m0; 14 15 public Proxy4(InvocationHandler paramInvocationHandler) 16 throws 17 { 18 super(paramInvocationHandler); 19 } 20 21 public final boolean equals(Object paramObject) 22 throws 23 { 24 try 25 { 26 return ((Boolean)this.h.invoke(this, m1, new Object[] { paramObject })).booleanValue(); 27 } 28 catch (RuntimeException localRuntimeException) 29 { 30 throw localRuntimeException; 31 } 32 catch (Throwable localThrowable) 33 { 34 throw new UndeclaredThrowableException(localThrowable); 35 } 36 } 37 38 public final String toString() 39 throws 40 { 41 try 42 { 43 return ((String)this.h.invoke(this, m2, null)); 44 } 45 catch (RuntimeException localRuntimeException) 46 { 47 throw localRuntimeException; 48 } 49 catch (Throwable localThrowable) 50 { 51 throw new UndeclaredThrowableException(localThrowable); 52 } 53 } 54 55 public final String test(String paramString) 56 throws 57 { 58 try 59 { 60 return ((String)this.h.invoke(this, m3, new Object[] { paramString })); 61 } 62 catch (RuntimeException localRuntimeException) 63 { 64 throw localRuntimeException; 65 } 66 catch (Throwable localThrowable) 67 { 68 throw new UndeclaredThrowableException(localThrowable); 69 } 70 } 71 72 public final int hashCode() 73 throws 74 { 75 try 76 { 77 return ((Integer)this.h.invoke(this, m0, null)).intValue(); 78 } 79 catch (RuntimeException localRuntimeException) 80 { 81 throw localRuntimeException; 82 } 83 catch (Throwable localThrowable) 84 { 85 throw new UndeclaredThrowableException(localThrowable); 86 } 87 } 88 89 static 90 { 91 try 92 { 93 m1 = Class.forName("java.lang.Object").getMethod("equals", new Class[] { Class.forName("java.lang.Object") }); 94 m2 = Class.forName("java.lang.Object").getMethod("toString", new Class[0]); 95 m3 = Class.forName("com.zkn.newlearn.gof.proxyhandler.PersonInter").getMethod("test", new Class[] { Class.forName("java.lang.String") }); 96 m0 = Class.forName("java.lang.Object").getMethod("hashCode", new Class[0]); 97 return; 98 } 99 catch (NoSuchMethodException localNoSuchMethodException) 100 { 101 throw new NoSuchMethodError(localNoSuchMethodException.getMessage()); 102 } 103 catch (ClassNotFoundException localClassNotFoundException) 104 { 105 throw new NoClassDefFoundError(localClassNotFoundException.getMessage()); 106 } 107 } 108 }
源码转载于:http://blog.csdn.net/zknxx/article/details/77919332