]> source.dussan.org Git - javassist.git/commitdiff
slightly changed the caching policy used by ProxyFactory
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Thu, 2 Nov 2006 14:30:22 +0000 (14:30 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Thu, 2 Nov 2006 14:30:22 +0000 (14:30 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@328 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/util/proxy/ProxyFactory.java

index f42714d8e54e4c1718e3b97b382d7887fce75d66..3dd5b1e6f05ac482287f82fd50edd080953478ec 100644 (file)
@@ -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;
         }