private void addProxyMethod(Method m,Class<?> fromClass){
  String name=m.getName();
  Class<?>[] parameterTypes=m.getParameterTypes();
  Class<?> returnType=m.getReturnType();
  Class<?>[] exceptionTypes=m.getExceptionTypes();
  String sig=name + getParameterDescriptors(parameterTypes);
  List<ProxyMethod> sigmethods=proxyMethods.get(sig);
  if (sigmethods != null) {
    for (    ProxyMethod pm : sigmethods) {
      if (returnType == pm.returnType) {
        List<Class<?>> legalExceptions=new ArrayList<>();
        collectCompatibleTypes(exceptionTypes,pm.exceptionTypes,legalExceptions);
        collectCompatibleTypes(pm.exceptionTypes,exceptionTypes,legalExceptions);
        pm.exceptionTypes=new Class<?>[legalExceptions.size()];
        pm.exceptionTypes=legalExceptions.toArray(pm.exceptionTypes);
        return;
      }
    }
  }
 else {
    sigmethods=new ArrayList<>(3);
    proxyMethods.put(sig,sigmethods);
  }
  sigmethods.add(new ProxyMethod(name,parameterTypes,returnType,exceptionTypes,fromClass));
}

private void addProxyMethod ( Method m , Class < ? > fromClass ) { String name = m . getName ( ) ; Class < ? > [ ] parameterTypes = m . getParameterTypes ( ) ; Class < ? > returnType = m . getReturnType ( ) ; Class < ? > [ ] exceptionTypes = m . getExceptionTypes ( ) ; String sig = name + getParameterDescriptors ( parameterTypes ) ; List < ProxyMethod > sigmethods = proxyMethods . get ( sig ) ; if ( sigmethods != null ) { for ( ProxyMethod pm : sigmethods ) { if ( returnType == pm . returnType ) { List < Class < ? > > legalExceptions = new ArrayList < > ( ) ; collectCompatibleTypes ( exceptionTypes , pm . exceptionTypes , legalExceptions ) ; collectCompatibleTypes ( pm . exceptionTypes , exceptionTypes , legalExceptions ) ; pm . exceptionTypes = new Class < ? > [ legalExceptions . size ( ) ] ; pm . exceptionTypes = legalExceptions . toArray ( pm . exceptionTypes ) ; return ; } } } else { sigmethods = new ArrayList < > ( 3 ) ; proxyMethods . put ( sig , sigmethods ) ; } sigmethods . add ( new ProxyMethod ( name , parameterTypes , returnType , exceptionTypes , fromClass ) ) ; }
add another method to be proxied , either by creating a new proxymethod object or augmenting an old one for a duplicate method . " fromclass " indicates the proxy interface that the method was found through , which may be different from ( a subinterface of ) the method ' s " declaring class " . note that the first method object passed for a given name and descriptor identifies the method object ( and thus the declaring class ) that will be passed to the invocation handler ' s " invoke " method for a given set of duplicate methods .
