This content has been marked as final.
Show 11 replies
-
1. Re: Reflect BeanInfo cache change breaks Kernel
alesj Nov 25, 2008 7:22 AM (in response to alesj)"alesj" wrote:
Looks like ClassInfo is not 'immune' to different classloaders.
Should I put back CL as additional key?
Putting CL back as key helps.
I'll do another release + add some tests for this CL issue. -
2. Re: Reflect BeanInfo cache change breaks Kernel
kabirkhan Nov 25, 2008 7:38 AM (in response to alesj)Can you let me know when you have commited this? I'd like to run the aop tests in AS trunk with this just to make double sure
-
3. Re: Reflect BeanInfo cache change breaks Kernel
adrian.brock Nov 25, 2008 7:41 AM (in response to alesj)"alesj" wrote:
Looks like ClassInfo is not 'immune' to different classloaders.
Should I put back CL as additional key?
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. -
4. Re: Reflect BeanInfo cache change breaks Kernel
alesj Nov 25, 2008 7:42 AM (in response to alesj)"kabir.khan@jboss.com" wrote:
Can you let me know when you have commited this? I'd like to run the aop tests in AS trunk with this just to make double sure
I've already deployed 2.2.0-SNAPSHOT, if you wanna test it. -
5. Re: Reflect BeanInfo cache change breaks Kernel
alesj Nov 25, 2008 8:01 AM (in response to alesj)"adrian@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? :-) -
6. Re: Reflect BeanInfo cache change breaks Kernel
alesj Nov 25, 2008 8:04 AM (in response to alesj)Missing detail:
package org.jboss.test.beaninfo.support; /** * BeanInfoEmpty. * * @author <a href="adrian@jboss.com">Adrian Brock</a> * @version $Revision: 1.1 $ */ public class BeanInfoEmpty { }
Same package as BeanInfoCache. -
7. Re: Reflect BeanInfo cache change breaks Kernel
kabirkhan Nov 25, 2008 8:07 AM (in response to alesj)The aop tests in AS trunk run fine with this snapshot
-
8. Re: Reflect BeanInfo cache change breaks Kernel
alesj Nov 25, 2008 8:11 AM (in response to alesj)"adrian@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.
How is this then different from what we already had?
CL + String (ClassInfo::getName) vs. CL + ClassInfo
But it must be different since the tests I added (similar to yours printCollection)
are now passing, where before they didn't. :-) -
9. Re: Reflect BeanInfo cache change breaks Kernel
alesj Nov 25, 2008 8:17 AM (in response to alesj)"alesj" wrote:
Where am I wrong?
Got it. ;-)
URLCL::parent must be explicitly set to null,
else it uses bootstrap/system CL as parent.String className = BeanInfoEmpty.class.getName(); Class<?> clazz = Class.forName(className); URL url1 = clazz.getProtectionDomain().getCodeSource().getLocation(); URL[] urls = {url1}; ClassLoader cl1 = new URLClassLoader(urls, null);
-
10. Re: Reflect BeanInfo cache change breaks Kernel
adrian.brock Nov 25, 2008 8:22 AM (in response to alesj)"alesj" wrote:
ClassLoader cl1 = new URLClassLoader(urls);
But BeanInfoCache's CL is always sun.misc.Launcher$AppClassLoader@a39137.
Although I would expect my URLCL.
Where am I wrong? :-)
You need a classloader that overrides loadClass() to not look at the parent.
The classloader you've constructed will just use the ClassLoader.getSystemClassLoader()
as the parent. i.e. the classpath -
11. Re: Reflect BeanInfo cache change breaks Kernel
alesj Nov 26, 2008 5:43 PM (in response to alesj)"alesj" wrote:
But it must be different since the tests I added (similar to yours printCollection)
are now passing, where before they didn't. :-)
It's different due to ClassInfoImpl::equals != DelegateClassInfo::equals.