"adrian(a)jboss.org" wrote :
| The issue is that the ClassInfo is not usable as a key to a map since it only
| checks the class name in the equals.
| i.e. it has no understanding of classloader.
I would expect this to fail:
| public void testClassLoaderCaching() throws Throwable
| {
| String className = BeanInfoEmpty.class.getName();
| Class<?> clazz = Class.forName(className);
| URL url1 = clazz.getProtectionDomain().getCodeSource().getLocation();
| URL[] urls = {url1};
| ClassLoader cl1 = new URLClassLoader(urls);
|
| className = ClassInfo.class.getName();
| clazz = Class.forName(className);
| URL url2 = clazz.getProtectionDomain().getCodeSource().getLocation();
| urls = new URL[]{url1, url2};
| ClassLoader cl2 = new URLClassLoader(urls);
|
| Configuration configuration = getConfiguration();
|
| ClassInfo ci1 = configuration.getClassInfo(className, cl1);
| ClassInfo ci2 = configuration.getClassInfo(className, cl2);
| assertSame(ci1, ci2);
| assertEquals(ci1.hashCode(), ci2.hashCode());
|
| className = "org.jboss.test.beaninfo.support.BeanInfoCache";
| BeanInfo bi1 = configuration.getBeanInfo(className, cl1);
| BeanInfo bi2 = configuration.getBeanInfo(className, cl2);
| assertFalse(bi1.equals(bi2)); // !-- HERE
| }
|
But BeanInfoCache's CL is always sun.misc.Launcher$AppClassLoader@a39137.
Although I would expect my URLCL.
Where am I wrong? :-)
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4192092#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...