From: chiba Date: Thu, 2 Nov 2006 14:30:22 +0000 (+0000) Subject: slightly changed the caching policy used by ProxyFactory X-Git-Tag: rel_3_17_1_ga~306 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=816d6d0b7f3925ae2dde862511e2df70806222c5;p=javassist.git slightly changed the caching policy used by ProxyFactory git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@328 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/src/main/javassist/util/proxy/ProxyFactory.java b/src/main/javassist/util/proxy/ProxyFactory.java index f42714d8..3dd5b1e6 100644 --- a/src/main/javassist/util/proxy/ProxyFactory.java +++ b/src/main/javassist/util/proxy/ProxyFactory.java @@ -141,11 +141,15 @@ public class ProxyFactory { private MethodFilter filter; private int hash; WeakReference proxyClass; + MethodHandler handler; - public CacheKey(Class superClass, Class[] interfaces, MethodFilter f) { + public CacheKey(Class superClass, Class[] interfaces, + MethodFilter f, MethodHandler h) + { classes = getKey(superClass, interfaces); hash = classes.hashCode(); filter = f; + handler = h; proxyClass = null; } @@ -154,7 +158,8 @@ public class ProxyFactory { public boolean equals(Object obj) { if (obj instanceof CacheKey) { CacheKey target = (CacheKey)obj; - return target.filter == filter && target.classes.equals(classes); + return target.filter == filter && target.handler == handler + && target.classes.equals(classes); } else return false; @@ -238,7 +243,7 @@ public class ProxyFactory { } private void createClass2(ClassLoader cl) { - CacheKey key = new CacheKey(superClass, interfaces, methodFilter); + CacheKey key = new CacheKey(superClass, interfaces, methodFilter, handler); synchronized (proxyCache) { HashMap cacheForTheLoader = (HashMap)proxyCache.get(cl); if (cacheForTheLoader == null) { @@ -276,7 +281,7 @@ public class ProxyFactory { WeakReference ref = key.proxyClass; if (ref != null) { Class c = (Class)ref.get(); - if(c != null && getHandler(c) == handler) + if(c != null) return c; }