Kabir Khan [
http://community.jboss.org/people/kabir.khan%40jboss.com] replied to the
discussion
"JBREFLECT-5 - Implementing generics in JavassistClassInfo"
To view the discussion, visit:
http://community.jboss.org/message/539766#539766
--------------------------------------------------------------
2 - classloader for parameterized type
I posted this last night right after my "1 - other problem", but could not see
it again today?!?
Anyway, for a test still using SomeSignature and SomeValue, but now uses the lazy feature
where I do something along the lines of
public void testClasses() throws Throwable
{
generateClasses();
ClassInfo info = (Classinfo)getTypeInfoFactory().getTypeInfo(SomeSignature.class);
MethodInfo mi = info.getDeclaredMethod("signature", new TypeInfo[0]);
ClassInfo returnInfo = mi.getReturnType(); //Constructs the parameterized class info
internally
TypeInfo[] args = returnInfo.getActualTypeArguments(); //* Lazily loads the type
arguments
}
This fails with the call to returnInfo.getActualTypeArguments()
java.lang.IllegalStateException: java.lang.ClassNotFoundException:
org.jboss.test.classinfo.test.JavassistParameterizedClassInfoClassLoaderArgumentsTestCaseWithSignature
at
org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.getTypeInfo(JavassistTypeInfoFactoryImpl.java:840)
at
org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.createTypeInfoForTypeArgument(JavassistTypeInfoFactoryImpl.java:898)
at
org.jboss.reflect.plugins.javassist.JavassistParameterizedClassInfo.getActualTypeArguments(JavassistParameterizedClassInfo.java:115)
....
Caused by: java.lang.ClassNotFoundException:
org.jboss.test.classinfo.test.JavassistParameterizedClassInfoClassLoaderArgumentsTestCaseWithSignature
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at
org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl.resolveComplexTypeInfo(IntrospectionTypeInfoFactoryImpl.java:434)
at
org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl.getTypeInfo(IntrospectionTypeInfoFactoryImpl.java:390)
at
org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory.getTypeInfo(IntrospectionTypeInfoFactory.java:54)
at
org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.delegateToIntrospectionImplementation(JavassistTypeInfoFactoryImpl.java:620)
at
org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.get(JavassistTypeInfoFactoryImpl.java:547)
at
org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.get(JavassistTypeInfoFactoryImpl.java:454)
at
org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.get(JavassistTypeInfoFactoryImpl.java:411)
at
org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl.getTypeInfo(JavassistTypeInfoFactoryImpl.java:836)
... 23 more
The reason is that I am using the classloader of the raw type (i.e. Set) to load up this
parameterized type, but obviously SomeValue cannot be found there.
One way around this would be in mi.getReturnType() when looking up/creating/caching the
parameterized class info to use the classloader of
mi.getDeclaringClass().getClassLoader(), which should be able to see all the classes
involved. However, I am still stuck on which classloader to use for my previous post.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/539766#539766]
Start a new discussion in JBoss Microcontainer Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]