zoukankan      html  css  js  c++  java
  • java-jdk动态代理生成的代理类源码

      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 }
    View Code

    源码转载于:http://blog.csdn.net/zknxx/article/details/77919332

  • 相关阅读:
    jmeter压测,json提取器的使用
    pycharm安装
    安装numpy+mkl
    Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
    windows上安装tensorflow时报错,“DLL load failed: 找不到指定的模块”的解决方式
    mapreduce 设置递归读取输入文件
    设置reduce Task数量
    kafka.common.FailedToSendMessageException: Failed to send messages after 3 tries.
    mahout RecommenderJob 参数含义
    idea 配置日志输出等级debug
  • 原文地址:https://www.cnblogs.com/dengrong/p/8533242.html
Copyright © 2011-2022 走看看