diff --git a/impl/src/main/java/org/jboss/cdi/tck/tests/build/compatible/extensions/registration/MyInterceptor.java b/impl/src/main/java/org/jboss/cdi/tck/tests/build/compatible/extensions/registration/MyInterceptor.java new file mode 100644 index 0000000000..b577f40b6c --- /dev/null +++ b/impl/src/main/java/org/jboss/cdi/tck/tests/build/compatible/extensions/registration/MyInterceptor.java @@ -0,0 +1,16 @@ +package org.jboss.cdi.tck.tests.build.compatible.extensions.registration; + +import jakarta.annotation.Priority; +import jakarta.interceptor.AroundInvoke; +import jakarta.interceptor.Interceptor; +import jakarta.interceptor.InvocationContext; + +@MyInterceptorBinding +@Interceptor +@Priority(1) +public class MyInterceptor { + @AroundInvoke + public Object intercept(InvocationContext ctx) throws Exception { + return ctx.proceed(); + } +} diff --git a/impl/src/main/java/org/jboss/cdi/tck/tests/build/compatible/extensions/registration/MyInterceptorBinding.java b/impl/src/main/java/org/jboss/cdi/tck/tests/build/compatible/extensions/registration/MyInterceptorBinding.java new file mode 100644 index 0000000000..056244cfbf --- /dev/null +++ b/impl/src/main/java/org/jboss/cdi/tck/tests/build/compatible/extensions/registration/MyInterceptorBinding.java @@ -0,0 +1,14 @@ +package org.jboss.cdi.tck.tests.build.compatible.extensions.registration; + +import jakarta.interceptor.InterceptorBinding; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@InterceptorBinding +public @interface MyInterceptorBinding { +} diff --git a/impl/src/main/java/org/jboss/cdi/tck/tests/build/compatible/extensions/registration/RegistrationExtension.java b/impl/src/main/java/org/jboss/cdi/tck/tests/build/compatible/extensions/registration/RegistrationExtension.java index 761a20471d..3418ac06e8 100644 --- a/impl/src/main/java/org/jboss/cdi/tck/tests/build/compatible/extensions/registration/RegistrationExtension.java +++ b/impl/src/main/java/org/jboss/cdi/tck/tests/build/compatible/extensions/registration/RegistrationExtension.java @@ -14,6 +14,7 @@ public class RegistrationExtension implements BuildCompatibleExtension { private final AtomicInteger beanCounter = new AtomicInteger(); private final AtomicInteger beanMyQualifierCounter = new AtomicInteger(); private final AtomicInteger observerCounter = new AtomicInteger(); + private final AtomicInteger interceptorCounter = new AtomicInteger(); @Registration(types = MyService.class) public void beans(BeanInfo bean) { @@ -31,6 +32,14 @@ public void observers(ObserverInfo observer, Types types) { } } + @Registration(types = MyInterceptor.class) + public void interceptors(BeanInfo interceptor, Messages msg) { + if (!interceptor.isInterceptor()) { + msg.error("Interceptor expected", interceptor); + } + interceptorCounter.incrementAndGet(); + } + @Validation public void test(Messages msg) { if (beanCounter.get() != 2) { @@ -44,5 +53,9 @@ public void test(Messages msg) { if (observerCounter.get() != 1) { msg.error("Should see 1 observer declared in class that implements MyService"); } + + if (interceptorCounter.get() != 1) { + msg.error("Should see 1 interceptor of type MyInterceptor"); + } } } diff --git a/lang-model/src/main/java/org/jboss/cdi/lang/model/tck/JavaLangObjectMethods.java b/lang-model/src/main/java/org/jboss/cdi/lang/model/tck/JavaLangObjectMethods.java new file mode 100644 index 0000000000..277264b8bc --- /dev/null +++ b/lang-model/src/main/java/org/jboss/cdi/lang/model/tck/JavaLangObjectMethods.java @@ -0,0 +1,15 @@ +package org.jboss.cdi.lang.model.tck; + +import jakarta.enterprise.lang.model.declarations.ClassInfo; + +public class JavaLangObjectMethods /*extends Object*/ { + public static class Verifier { + public static void verify(ClassInfo clazz) { + assert clazz.methods().isEmpty(); + + ClassInfo javaLangObject = clazz.superClassDeclaration(); + assert !javaLangObject.methods().isEmpty(); + assert LangModelUtils.collectMethods(javaLangObject, "toString").size() == 1; + } + } +} diff --git a/lang-model/src/main/java/org/jboss/cdi/lang/model/tck/LangModelVerifier.java b/lang-model/src/main/java/org/jboss/cdi/lang/model/tck/LangModelVerifier.java index e71d8ffac8..a09ed66570 100644 --- a/lang-model/src/main/java/org/jboss/cdi/lang/model/tck/LangModelVerifier.java +++ b/lang-model/src/main/java/org/jboss/cdi/lang/model/tck/LangModelVerifier.java @@ -46,6 +46,8 @@ public class LangModelVerifier { InheritedFields inheritedFields; InheritedAnnotations inheritedAnnotations; + JavaLangObjectMethods javaLangObjectMethods; + PrimitiveTypes primitiveTypes; BridgeMethods bridgeMethods; RepeatableAnnotations repeatableAnnotations; @@ -79,6 +81,8 @@ public static void verify(ClassInfo clazz) { InheritedFields.Verifier.verify(LangModelUtils.classOfField(clazz, "inheritedFields")); InheritedAnnotations.verify(LangModelUtils.classOfField(clazz, "inheritedAnnotations")); + JavaLangObjectMethods.Verifier.verify(LangModelUtils.classOfField(clazz, "javaLangObjectMethods")); + PrimitiveTypes.verify(LangModelUtils.classOfField(clazz, "primitiveTypes")); BridgeMethods.verify(LangModelUtils.classOfField(clazz, "bridgeMethods")); RepeatableAnnotations.verify(LangModelUtils.classOfField(clazz, "repeatableAnnotations"));