With this just remember that there can be >1 WeldClass per real class!

Sure, but I think we shouldn't wrap existing WeldClass impls -- else we end-up with dups.
(unless we then properly impl equals/hash, which is a pita in this case ...)

I've added this to ClassTransformer:

    public <T> WeldClass<T> loadClass(final AnnotatedType<T> clazz) {
        // don't wrap existing weld class, dup instances!
       if (clazz instanceof WeldClass) {
            return (WeldClass<T>) clazz;
        } else if (clazz instanceof ForwardingAnnotatedType && ((ForwardingAnnotatedType) clazz).delegate() instanceof WeldClass) {
            ForwardingAnnotatedType fat = (ForwardingAnnotatedType) clazz;
            return (WeldClass<T>) fat.delegate();
        } else {
            return (WeldClass<T>) annotatedTypes.get(clazz);

"Bar extends Foo"

The problem is that both Bar and Foo are added as AnnotatedType against ClassTransformer,
and eventually deployed as such.

But WeldClassImpl::superclass is looked-up against ClassTransformer::classes --> diff WC_Foo instances


   private final ConcurrentMap<TypeHolder<?>, WeldClass<?>> classes;
   private final ConcurrentMap<AnnotatedType<?>, WeldClass<?>> annotatedTypes;

... and no equals/hash impl on WeldClassImpl ...

WELD-802 is due to WeldClassImpl not being the same for same class:

clazz = {java.lang.Class@5703}"class org.jboss.weld.tests.specialization.weld802.Foo"
weldClass = {org.jboss.weld.introspector.jlr.WeldClassImpl@5687}"public@RequestScoped class org.jboss.weld.tests.specialization.weld802.Foo"


key: org.jboss.weld.introspector.jlr.WeldClassImpl = {org.jboss.weld.introspector.jlr.WeldClassImpl@5709}"public@RequestScoped class org.jboss.weld.tests.specialization.weld802.Foo"
value: org.jboss.weld.bean.ManagedBean = {org.jboss.weld.bean.ManagedBean@5961}"Managed Bean [class org.jboss.weld.tests.specialization.weld802.Foo] with qualifiers [@Any @Default]"

... investigating further ...

weld-dev mailing list