Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WELD-2798 Secondary idea #3065

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions .github/workflows/ci-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3.12.0
uses: actions/setup-java@v4.2.1
with:
java-version: 11
distribution: 'temurin'
Expand All @@ -35,7 +35,7 @@ jobs:
shell: bash
- name: Cache Maven Repository
id: cache-maven
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2/repository
# Caching is an automated pre/post action that installs the cache if the key exists and exports the cache
Expand All @@ -54,15 +54,15 @@ jobs:
zip -r wildfly.zip wildfly
cd ..
- name: Persist WildFly
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wildfly-patched-zip
path: container/wildfly.zip
- name: Tar Maven Repo
shell: bash
run: tar -czf maven-repo.tgz -C ~ .m2/repository
- name: Persist Maven Repo
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: maven-repo
path: maven-repo.tgz
Expand Down Expand Up @@ -94,20 +94,20 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java.name }}
uses: actions/setup-java@v3.12.0
uses: actions/setup-java@v4.2.1
with:
java-version: ${{ matrix.java.java-version }}
distribution: 'temurin'
- name: Download Maven Repo
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: maven-repo
path: .
- name: Extract Maven Repo
shell: bash
run: tar -xzf maven-repo.tgz -C ~
- name: Download Patched WildFly
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: wildfly-patched-zip
path: .
Expand All @@ -125,13 +125,13 @@ jobs:
find . -name '*-reports' -type d | tar -czf test-reports.tgz -T -
find . -name 'server.log' -type f | tar -czf server-log.tgz -T -
- name: Upload failure Archive (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-reports-incontainer-jdk${{matrix.java.name}}
path: 'test-reports.tgz'
- name: Upload server log artifact (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: server-log-incontainer-jdk${{matrix.java.name}}
Expand Down Expand Up @@ -161,20 +161,20 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java.name }}
uses: actions/setup-java@v3.12.0
uses: actions/setup-java@v4.2.1
with:
java-version: ${{ matrix.java.java-version }}
distribution: 'temurin'
- name: Download Maven Repo
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: maven-repo
path: .
- name: Extract Maven Repo
shell: bash
run: tar -xzf maven-repo.tgz -C ~
- name: Download Patched WildFly
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: wildfly-patched-zip
path: .
Expand All @@ -192,13 +192,13 @@ jobs:
find . -name '*-reports' -type d | tar -czf test-reports.tgz -T -
find . -name 'server.log' -type f | tar -czf server-log.tgz -T -
- name: Upload failure Archive (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-reports-cdi-tck-jdk${{matrix.java.name}}
path: 'test-reports.tgz'
- name: Upload server log artifact (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: server-log-cdi-tck-jdk${{matrix.java.name}}
Expand All @@ -220,20 +220,20 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java.name }}
uses: actions/setup-java@v3.12.0
uses: actions/setup-java@v4.2.1
with:
java-version: ${{ matrix.java.java-version }}
distribution: 'temurin'
- name: Download Maven Repo
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4
with:
name: maven-repo
path: .
- name: Extract Maven Repo
shell: bash
run: tar -xzf maven-repo.tgz -C ~
- name: Download Patched WildFly
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: wildfly-patched-zip
path: .
Expand All @@ -251,13 +251,13 @@ jobs:
find . -name '*-reports' -type d | tar -czf test-reports.tgz -T -
find . -name 'server.log' -type f | tar -czf server-log.tgz -T -
- name: Upload failure Archive (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-reports-cdi-tck-jdk${{matrix.java.name}}-incontainer-relaxed
path: 'test-reports.tgz'
- name: Upload server log artifact (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: server-log-cdi-tck-jdk${{matrix.java.name}}
Expand All @@ -270,7 +270,7 @@ jobs:
shell: bash
run: find . -name '*-reports' -type d | tar -czf test-reports.tgz -T -
- name: Upload failure Archive (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-reports-cdi-tck-jdk${{matrix.java.name}}-relaxed
Expand Down Expand Up @@ -300,12 +300,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java.name }}
uses: actions/setup-java@v3.12.0
uses: actions/setup-java@v4.2.1
with:
java-version: ${{ matrix.java.java-version }}
distribution: 'temurin'
- name: Download Maven Repo
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: maven-repo
path: .
Expand All @@ -320,7 +320,7 @@ jobs:
shell: bash
run: find . -name '*-reports' -type d | tar -czf test-reports.tgz -T -
- name: Upload failure Archive (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-reports-no-container-jdk${{matrix.java.name}}
Expand All @@ -335,20 +335,20 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3.12.0
uses: actions/setup-java@v4.2.1
with:
java-version: 11
distribution: 'temurin'
- name: Download Maven Repo
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: maven-repo
path: .
- name: Extract Maven Repo
shell: bash
run: tar -xzf maven-repo.tgz -C ~
- name: Download Patched WildFly
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: wildfly-patched-zip
path: .
Expand All @@ -366,13 +366,13 @@ jobs:
find . -name '*-reports' -type d | tar -czf test-reports.tgz -T -
find . -name 'server.log' -type f | tar -czf server-log.tgz -T -
- name: Upload failed tests artifact (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-reports-examples
path: 'test-reports.tgz'
- name: Upload server log artifact (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: server-log-examples
Expand Down Expand Up @@ -402,12 +402,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java.name }}
uses: actions/setup-java@v3.12.0
uses: actions/setup-java@v4.2.1
with:
java-version: ${{ matrix.java.java-version }}
distribution: 'temurin'
- name: Download Maven Repo
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: maven-repo
path: .
Expand All @@ -422,7 +422,7 @@ jobs:
shell: bash
run: find . -name '*-reports' -type d | tar -czf test-reports.tgz -T -
- name: Upload failure Archive (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-reports-cdi-tck-se-jdk${{matrix.java.name}}
Expand All @@ -437,12 +437,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3.12.0
uses: actions/setup-java@v4.2.1
with:
java-version: 11
distribution: 'temurin'
- name: Download Maven Repo
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: maven-repo
path: .
Expand All @@ -457,7 +457,7 @@ jobs:
shell: bash
run: find . -name '*-reports' -type d | tar -czf test-reports.tgz -T -
- name: Upload failure Archive (if maven failed)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-reports-se-servlet-coop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public interface EnhancedAnnotatedType<T> extends EnhancedAnnotated<T, Class<T>>
* @return A set of abstracted fields with the given annotation. Returns an
* empty set if there are no matches
*/
Collection<EnhancedAnnotatedField<?, ?>> getEnhancedFields(Class<? extends Annotation> annotationType);
Collection<EnhancedAnnotatedField<?, ? super T>> getEnhancedFields(Class<? extends Annotation> annotationType);

/**
* Gets all fields declared on this class only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -71,17 +68,6 @@
*/
public class EnhancedAnnotatedTypeImpl<T> extends AbstractEnhancedAnnotated<T, Class<T>> implements EnhancedAnnotatedType<T> {

private static final Set<Class<? extends Annotation>> MAPPED_METHOD_ANNOTATIONS;

static {
Set<Class<? extends Annotation>> annotations = new HashSet<Class<? extends Annotation>>();
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<Class<? extends Annotation>> MAPPED_METHOD_PARAMETER_ANNOTATIONS = ImmutableSet.of(Observes.class,
ObservesAsync.class);
Expand All @@ -95,7 +81,7 @@ public class EnhancedAnnotatedTypeImpl<T> extends AbstractEnhancedAnnotated<T, C
// The set of abstracted fields
private final Set<EnhancedAnnotatedField<?, ? super T>> fields;
// The map from annotation type to abstracted field with annotation
private final Multimap<Class<? extends Annotation>, EnhancedAnnotatedField<?, ?>> annotatedFields;
private final Multimap<Class<? extends Annotation>, EnhancedAnnotatedField<?, ? super T>> annotatedFields;

// The set of abstracted fields
private final Set<EnhancedAnnotatedField<?, ? super T>> declaredFields;
Expand Down Expand Up @@ -158,7 +144,14 @@ protected EnhancedAnnotatedTypeImpl(SlimAnnotatedType<T> annotatedType,
this.superclass = classTransformer.getEnhancedAnnotatedType(superclass, slim.getIdentifier().getBdaId());
}
} else {
this.superclass = classTransformer.getEnhancedAnnotatedType(Object.class, AnnotatedTypeIdentifier.NULL_BDA_ID);
EnhancedAnnotatedType<? super T> superclassAt;
Class<? super T> superclass = annotatedType.getJavaClass().getSuperclass();
if (superclass == null) {
superclassAt = classTransformer.getEnhancedAnnotatedType(Object.class, AnnotatedTypeIdentifier.NULL_BDA_ID);
} else {
superclassAt = classTransformer.getEnhancedAnnotatedType(superclass, slim.getIdentifier().getBdaId());
}
this.superclass = superclassAt;
}

// Assign class field information
Expand Down Expand Up @@ -189,7 +182,7 @@ protected EnhancedAnnotatedTypeImpl(SlimAnnotatedType<T> annotatedType,
}
this.declaredFields = new HashSet<EnhancedAnnotatedField<?, ? super T>>(declaredFieldsTemp);
} else {
Multimap<Class<? extends Annotation>, EnhancedAnnotatedField<?, ?>> annotatedFields = new ListMultimap<Class<? extends Annotation>, EnhancedAnnotatedField<?, ?>>();
Multimap<Class<? extends Annotation>, EnhancedAnnotatedField<?, ? super T>> annotatedFields = new ListMultimap<>();
fieldsTemp = new HashSet<EnhancedAnnotatedField<?, ? super T>>();
for (AnnotatedField<? super T> annotatedField : annotatedType.getFields()) {
EnhancedAnnotatedField<?, ? super T> weldField = EnhancedAnnotatedFieldImpl.of(annotatedField, this,
Expand Down Expand Up @@ -345,10 +338,8 @@ protected EnhancedAnnotatedTypeImpl(SlimAnnotatedType<T> annotatedType,
Set<EnhancedAnnotatedMethod<?, ? super T>> effectiveMethods) {
Multimap<Class<? extends Annotation>, EnhancedAnnotatedMethod<?, ? super T>> result = SetMultimap.newSetMultimap();
for (EnhancedAnnotatedMethod<?, ? super T> method : effectiveMethods) {
for (Class<? extends Annotation> annotation : MAPPED_METHOD_ANNOTATIONS) {
if (method.isAnnotationPresent(annotation)) {
result.put(annotation, method);
}
for (Annotation ann : method.getAnnotations()) {
result.put(ann.annotationType(), method);
Comment on lines +341 to +342
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not needed for the PR but fixes the inconsistency in the code - previously the collection of annotated methods only contained methods with certain annotations. This changes it to instead know about all annotated methods in given AT - which is what the API javadoc for EnhancedAnnotatedType#getEnhancedMethods(Class) states to begin with

}
}
return Multimaps.unmodifiableMultimap(result);
Expand Down Expand Up @@ -443,10 +434,10 @@ public EnhancedAnnotatedConstructor<T> getDeclaredEnhancedConstructor(Constructo
* @return A set of matching abstracted fields, null if none are found.
*/
@Override
public Collection<EnhancedAnnotatedField<?, ?>> getEnhancedFields(Class<? extends Annotation> annotationType) {
public Collection<EnhancedAnnotatedField<?, ? super T>> getEnhancedFields(Class<? extends Annotation> annotationType) {
if (annotatedFields == null) {
// Build collection from class hierarchy
ArrayList<EnhancedAnnotatedField<?, ?>> aggregatedFields = new ArrayList<EnhancedAnnotatedField<?, ?>>(
ArrayList<EnhancedAnnotatedField<?, ? super T>> aggregatedFields = new ArrayList<>(
this.declaredAnnotatedFields.get(annotationType));
if ((superclass != null) && (superclass.getJavaClass() != Object.class)) {
aggregatedFields.addAll(superclass.getEnhancedFields(annotationType));
Expand Down Expand Up @@ -490,8 +481,6 @@ public boolean isSerializable() {

/**
* Gets the abstracted methods that have a certain annotation type present
* <p/>
* 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
Expand Down
Loading
Loading