[jboss-cvs] JBossAS SVN: r104477 - projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed May 5 10:03:50 EDT 2010
Author: kabir.khan at jboss.com
Date: 2010-05-05 10:03:49 -0400 (Wed, 05 May 2010)
New Revision: 104477
Modified:
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
Log:
[JBREFLECT-5] Make sure that if we can't find the typeinfo in the requesting classloader, and need to load up the CtClass that we check the cache of the CtClass.getClassPool().getClassLoader() to avoid duplicate typeinfos
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java 2010-05-05 13:45:30 UTC (rev 104476)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java 2010-05-05 14:03:49 UTC (rev 104477)
@@ -537,11 +537,22 @@
if (result != null)
return result;
+ boolean changedCache = false;
try
{
if (ctClass == null)
{
ctClass = poolFactory.getPoolForLoader(cl).get(name);
+ ClassLoader realLoader = ctClass.getClassPool().getClassLoader();
+ if (realLoader != null && realLoader != cl)
+ {
+ //Make sure that we check the cache of the classloader actually containing the class
+ changedCache = true;
+ classLoaderCache = getClassLoaderCache(realLoader);
+ result = getFromCache(name, classLoaderCache);
+ if (result != null)
+ return result;
+ }
}
result = instantiate(ctClass, clazz);
}
@@ -553,9 +564,13 @@
throw new RuntimeException(e);
}
- ClassLoader realLoader = getClassLoader(result);
- if (realLoader != cl)
- classLoaderCache = getClassLoaderCache(realLoader);
+ if (!changedCache)
+ {
+ //Make sure that we cache against the classloader actually containing the class
+ ClassLoader realLoader = getClassLoader(result);
+ if (realLoader != cl)
+ classLoaderCache = getClassLoaderCache(realLoader);
+ }
WeakReference<TypeInfo>weak = new WeakReference<TypeInfo>(result);
classLoaderCache.put(name, weak);
More information about the jboss-cvs-commits
mailing list