Skip to content

Commit 8783197

Browse files
committed
Support multiple annotation version in E4 Injector
and specifically support jakarta.annotation version 3.0. Fixes #1565
1 parent 0dd7f8e commit 8783197

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

runtime/bundles/org.eclipse.e4.core.di/META-INF/MANIFEST.MF

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Export-Package: org.eclipse.e4.core.di;version="1.7.0",
1515
org.eclipse.e4.core.internal.di.osgi;x-internal:=true,
1616
org.eclipse.e4.core.internal.di.shared;x-friends:="org.eclipse.e4.core.contexts,org.eclipse.e4.core.di.extensions.supplier"
1717
Require-Bundle: org.eclipse.e4.core.di.annotations;bundle-version="[1.4.0,2.0.0)";visibility:=reexport
18-
Import-Package: jakarta.annotation;version="[2,3)",
18+
Import-Package: jakarta.annotation;version="[2,4)",
1919
jakarta.inject;version="[2,3)",
2020
javax.annotation;version="[1.3.0,2.0.0)";resolution:=optional,
2121
javax.inject;version="[1.0.0,2.0.0)";resolution:=optional,

runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/AnnotationLookup.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ public class AnnotationLookup {
4242
private AnnotationLookup() {
4343
}
4444

45-
public static record AnnotationProxy(List<Class<? extends Annotation>> classes) {
46-
public AnnotationProxy {
47-
classes = List.copyOf(classes);
45+
static record AnnotationProxy(List<Class<? extends Annotation>> classes, List<String> classNames) {
46+
47+
public AnnotationProxy(List<Class<? extends Annotation>> classes) {
48+
this(List.copyOf(classes), classes.stream().map(Class::getCanonicalName).toList());
4849
}
4950

5051
public boolean isPresent(AnnotatedElement element) {
51-
for (Class<? extends Annotation> annotationClass : classes) {
52-
if (element.isAnnotationPresent(annotationClass)) {
52+
for (Annotation annotation : element.getAnnotations()) {
53+
if (classNames.contains(annotation.annotationType().getCanonicalName())) {
5354
return true;
5455
}
5556
}

0 commit comments

Comments
 (0)