1 Reply Latest reply on Apr 19, 2010 5:43 PM by kabirkhan

    Duplicate classloading with Javassist Reflect

    alesj

      I'm getting this unexpected behavior while testing my Scanning lib.

       

      org.jboss.reflect.spi.CannotCompileException: javassist.CannotCompileException: by java.lang.LinkageError: loader (instance of  org/jboss/classloader/spi/base/BaseClassLoader): attempted  duplicate class definition for name: "org/jboss/test/scanning/annotations/support/FilteredAnnotationScanningPluginFactory"
          at org.jboss.reflect.plugins.javassist.JavassistUtil.ctClassToClass(JavassistUtil.java:56)
          at org.jboss.reflect.plugins.javassist.JavassistTypeInfo.getType(JavassistTypeInfo.java:195)
          at org.jboss.metadata.spi.signature.Signature.convertParameterTypes(Signature.java:151)
          at org.jboss.metadata.spi.signature.ConstructorSignature.<init>(ConstructorSignature.java:77)
          at org.jboss.metadata.spi.signature.Signature.getSignature(Signature.java:121)
          at org.jboss.scanning.plugins.visitor.ClassHierarchyResourceVisitor.handleAnnotations(ClassHierarchyResourceVisitor.java:200)

       

      I think this should not happen, since there should be only one instance of matching TypeInfo/ClassInfo.

       

      But it looks like we're missing a check if the CtClass is already loaded by the underlying classloader inside that TI/CI instance.

      Or some other mechanism that would prevent it from getting this duplicate behavior.