diff --git a/impl/src/main/java/org/jboss/weld/annotated/enhanced/jlr/EnhancedAnnotatedTypeImpl.java b/impl/src/main/java/org/jboss/weld/annotated/enhanced/jlr/EnhancedAnnotatedTypeImpl.java index 3bb9403ef8..4572a29c5c 100644 --- a/impl/src/main/java/org/jboss/weld/annotated/enhanced/jlr/EnhancedAnnotatedTypeImpl.java +++ b/impl/src/main/java/org/jboss/weld/annotated/enhanced/jlr/EnhancedAnnotatedTypeImpl.java @@ -34,7 +34,6 @@ import jakarta.enterprise.inject.spi.AnnotatedConstructor; import jakarta.enterprise.inject.spi.AnnotatedField; import jakarta.enterprise.inject.spi.AnnotatedMethod; -import jakarta.inject.Inject; import org.jboss.weld.annotated.enhanced.ConstructorSignature; import org.jboss.weld.annotated.enhanced.EnhancedAnnotatedConstructor; @@ -45,8 +44,6 @@ import org.jboss.weld.annotated.slim.AnnotatedTypeIdentifier; import org.jboss.weld.annotated.slim.SlimAnnotatedType; import org.jboss.weld.annotated.slim.backed.BackedAnnotatedType; -import org.jboss.weld.interceptor.spi.model.InterceptionType; -import org.jboss.weld.interceptor.util.InterceptionTypeRegistry; import org.jboss.weld.resources.ClassTransformer; import org.jboss.weld.util.collections.ImmutableSet; import org.jboss.weld.util.collections.ListMultimap; @@ -71,17 +68,6 @@ */ public class EnhancedAnnotatedTypeImpl extends AbstractEnhancedAnnotated> implements EnhancedAnnotatedType { - private static final Set> MAPPED_METHOD_ANNOTATIONS; - - static { - Set> annotations = new HashSet>(); - for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes()) { - annotations.add(InterceptionTypeRegistry.getAnnotationClass(interceptionType)); - } - annotations.add(Inject.class); - MAPPED_METHOD_ANNOTATIONS = ImmutableSet.copyOf(annotations); - } - @SuppressFBWarnings("unchecked") private static final Set> MAPPED_METHOD_PARAMETER_ANNOTATIONS = ImmutableSet.of(Observes.class, ObservesAsync.class); @@ -158,7 +144,18 @@ protected EnhancedAnnotatedTypeImpl(SlimAnnotatedType annotatedType, this.superclass = classTransformer.getEnhancedAnnotatedType(superclass, slim.getIdentifier().getBdaId()); } } else { - this.superclass = classTransformer.getEnhancedAnnotatedType(Object.class, AnnotatedTypeIdentifier.NULL_BDA_ID); + // TODO do we need the try-catch block? Since the class comes from an extension, do we always have access to it superclasses? + EnhancedAnnotatedType superclassAt = null; + try { + Class superclass = annotatedType.getJavaClass().getSuperclass(); + if (superclass != null) { + superclassAt = classTransformer.getEnhancedAnnotatedType(superclass, slim.getIdentifier().getBdaId()); + } + } catch (Exception e) { + // fallback, we just use Object as superclass + superclassAt = classTransformer.getEnhancedAnnotatedType(Object.class, AnnotatedTypeIdentifier.NULL_BDA_ID); + } + this.superclass = superclassAt; } // Assign class field information @@ -345,10 +342,8 @@ protected EnhancedAnnotatedTypeImpl(SlimAnnotatedType annotatedType, Set> effectiveMethods) { Multimap, EnhancedAnnotatedMethod> result = SetMultimap.newSetMultimap(); for (EnhancedAnnotatedMethod method : effectiveMethods) { - for (Class annotation : MAPPED_METHOD_ANNOTATIONS) { - if (method.isAnnotationPresent(annotation)) { - result.put(annotation, method); - } + for (Annotation ann : method.getAnnotations()) { + result.put(ann.annotationType(), method); } } return Multimaps.unmodifiableMultimap(result); @@ -490,8 +485,6 @@ public boolean isSerializable() { /** * Gets the abstracted methods that have a certain annotation type present - *

- * If the annotated methods map is null, initialize it first * * @param annotationType The annotation type to match * @return A set of matching method abstractions. Returns an empty set if no diff --git a/impl/src/main/java/org/jboss/weld/injection/ResourceInjectionProcessor.java b/impl/src/main/java/org/jboss/weld/injection/ResourceInjectionProcessor.java index 1a742b2aa6..eb19fd9b2a 100644 --- a/impl/src/main/java/org/jboss/weld/injection/ResourceInjectionProcessor.java +++ b/impl/src/main/java/org/jboss/weld/injection/ResourceInjectionProcessor.java @@ -90,7 +90,7 @@ protected Set> createResourceInjections(Bean declari } Class marker = getMarkerAnnotation(processorContext); - final Collection> fields = type.getEnhancedFields(marker); + final Collection> fields = type.getDeclaredEnhancedFields(marker); final Collection> methods = type.getDeclaredEnhancedMethods(marker); return createResourceInjections(fields, methods, declaringBean, type.getJavaClass(), manager);