Skip to content

Commit bb39d26

Browse files
authored
Merge pull request #31702 from Ladicek/arc-fixes
ArC fixes for spec compatibility, round 5
2 parents d65ba11 + a7a8c9e commit bb39d26

File tree

62 files changed

+1663
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1663
-198
lines changed

docs/src/main/asciidoc/cdi-reference.adoc

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ include::_attributes.adoc[]
1111
:sectnums:
1212
:sectnumlevels: 4
1313

14-
Quarkus DI solution (also called ArC) is based on the https://jakarta.ee/specifications/cdi/2.0/cdi-spec-2.0.html[Contexts and Dependency Injection for Java 2.0, window="_blank"] specification.
15-
However, it is not a full CDI implementation verified by the TCK.
16-
Only a subset of the CDI features is implemented - see also <<supported_features,the list of supported features>> and <<limitations,the list of limitations>>.
14+
Quarkus DI solution (also called ArC) is based on the https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0.html[Jakarta Contexts and Dependency Injection 4.0, window="_blank"] specification.
15+
It aims to implement the CDI Lite specification, with selected improvements on top.
16+
It is not a CDI Full implementation and is not verified by the TCK yet.
17+
See also <<supported_features,the list of supported features>> and <<limitations,the list of limitations>>.
1718
1819
TIP: If you're new to CDI then we recommend you to read the xref:cdi.adoc[Introduction to CDI] first.
1920
@@ -741,6 +742,7 @@ class Services {
741742
+
742743
NOTE: Interceptors can use `InvocationContext.getMethod()` to detect static methods and adjust the behavior accordingly.
743744

745+
[[unproxyable_classes_transformation]]
744746
=== Ability to handle 'final' classes and methods
745747

746748
In normal CDI, classes that are marked as `final` and / or have `final` methods are not eligible for proxy creation,
@@ -1081,6 +1083,32 @@ NOTE: These endpoints are only available in the development mode, i.e. when you
10811083
In the development mode, it is also possible to enable monitoring of business method invocations and fired events.
10821084
Simply set the `quarkus.arc.dev-mode.monitoring-enabled` configuration property to `true` and explore the relevant Dev UI pages.
10831085

1086+
[[strict_mode]]
1087+
== Strict Mode
1088+
1089+
By default, ArC does not perform all validations required by the CDI specification.
1090+
It also improves CDI usability in many ways, some of them being directly against the specification.
1091+
1092+
To be able to eventually pass the CDI Lite TCK, ArC also has a _strict_ mode.
1093+
This mode enables additional validations and disables certain improvements that conflict with the specification.
1094+
1095+
To enable the strict mode, use the following configuration:
1096+
1097+
[source,properties]
1098+
----
1099+
quarkus.arc.strict-compatibility=true
1100+
----
1101+
1102+
Some other features affect specification compatibility as well:
1103+
1104+
* <<unproxyable_classes_transformation,Transformation of unproxyable classes>>
1105+
* <<remove_unused_beans,Unused beans removal>>
1106+
1107+
To get a behavior closer to the specification, these features should also be disabled.
1108+
1109+
Applications are recommended to use the default, non-strict mode, which makes CDI more convenient to use.
1110+
The "strictness" of the strict mode (the set of additional validations and the set of disabled improvements on top of the CDI specification) may change over time.
1111+
10841112
[[arc-configuration-reference]]
10851113
== ArC Configuration Reference
10861114

extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcConfig.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,22 @@ public class ArcConfig {
177177
@ConfigItem(defaultValue = "true")
178178
public boolean detectWrongAnnotations;
179179

180+
/**
181+
* If set to {@code true}, the container will perform additional validations mandated by the CDI specification.
182+
* Some improvements on top of the CDI specification may be disabled. Applications that work as expected
183+
* in the strict mode should work without a change in the default, non-strict mode.
184+
* <p>
185+
* The strict mode is mainly introduced to allow passing the CDI Lite TCK. Applications are recommended
186+
* to use the default, non-strict mode, which makes CDI more convenient to use. The "strictness" of
187+
* the strict mode (the set of additional validations and the set of disabled improvements on top of
188+
* the CDI specification) may change over time.
189+
* <p>
190+
* Note that {@link #transformUnproxyableClasses} and {@link #removeUnusedBeans} also has effect on specification
191+
* compatibility. You may want to disable these features to get behavior closer to the specification.
192+
*/
193+
@ConfigItem(defaultValue = "false")
194+
public boolean strictCompatibility;
195+
180196
/**
181197
* Dev mode configuration.
182198
*/

extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ public boolean test(BeanInfo bean) {
373373
builder.setJtaCapabilities(capabilities.isPresent(Capability.TRANSACTIONS));
374374
builder.setGenerateSources(BootstrapDebug.DEBUG_SOURCES_DIR != null);
375375
builder.setAllowMocking(launchModeBuildItem.getLaunchMode() == LaunchMode.TEST);
376+
builder.setStrictCompatibility(arcConfig.strictCompatibility);
376377

377378
if (arcConfig.selectedAlternatives.isPresent()) {
378379
final List<Predicate<ClassInfo>> selectedAlternatives = initClassPredicates(

independent-projects/arc/arquillian/src/main/java/io/quarkus/arc/arquillian/Deployer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ private void generate() throws IOException, ExecutionException, InterruptedExcep
129129
Thread.currentThread().getContextClassLoader(), new ConcurrentHashMap<>(),
130130
beanArchiveIndex))
131131
.setApplicationIndex(applicationIndex)
132+
.setStrictCompatibility(true)
133+
.setTransformUnproxyableClasses(false)
134+
.setRemoveUnusedBeans(false)
132135
.setBuildCompatibleExtensions(buildCompatibleExtensions)
133136
.setAdditionalBeanDefiningAnnotations(Set.of(new BeanDefiningAnnotation(
134137
DotName.createSimple(ExtraBean.class.getName()), null)))

independent-projects/arc/cdi-tck-runner/src/test/resources/testng.xml

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@
4343
<exclude name="testContextualDestroyCatchesException"/>
4444
</methods>
4545
</class>
46-
<class name="org.jboss.cdi.tck.tests.implementation.initializer.broken.generic.GenericInitializerMethodTest">
47-
<methods>
48-
<exclude name="testGenericInitializerMethodNotAllowed"/>
49-
</methods>
50-
</class>
5146
<class name="org.jboss.cdi.tck.interceptors.tests.contract.lifecycleCallback.LifecycleCallbackInterceptorTest">
5247
<methods>
5348
<exclude name="testPostConstructInterceptor"/>
@@ -61,11 +56,6 @@
6156
<exclude name="testPublicLifecycleInterceptorMethod"/>
6257
</methods>
6358
</class>
64-
<class name="org.jboss.cdi.tck.tests.implementation.disposal.method.definition.broken.unresolvedMethod.UnresolvedDisposalMethodDefinitionTest">
65-
<methods>
66-
<exclude name="testUnresolvedDisposalMethod"/>
67-
</methods>
68-
</class>
6959
<class name="org.jboss.cdi.tck.interceptors.tests.contract.invocationContext.InvocationContextTest">
7060
<methods>
7161
<exclude name="testGetTargetMethod"/>
@@ -85,16 +75,6 @@
8575
<exclude name="testTooManyScopesSpecifiedInJava"/>
8676
</methods>
8777
</class>
88-
<class name="org.jboss.cdi.tck.tests.implementation.producer.method.broken.parameterizedTypeWithTypeParameter.ParameterizedReturnTypeWithTypeVariableTest">
89-
<methods>
90-
<exclude name="testNonDependentScopedProducerMethodWithParameterizedTypeWithTypeVariable"/>
91-
</methods>
92-
</class>
93-
<class name="org.jboss.cdi.tck.tests.interceptors.definition.broken.nonDependent.NonDependentInterceptorTest">
94-
<methods>
95-
<exclude name="testDeploymentWithScopedInterceptor"/>
96-
</methods>
97-
</class>
9878
<class name="org.jboss.cdi.tck.interceptors.tests.contract.lifecycleCallback.exceptions.LifecycleCallbackInterceptorExceptionTest">
9979
<methods>
10080
<exclude name="testLifecycleCallbackInterceptorCanCatchException"/>
@@ -165,20 +145,6 @@
165145
<exclude name="testExceptions"/>
166146
</methods>
167147
</class>
168-
<class name="org.jboss.cdi.tck.tests.interceptors.invocation.InterceptorInvocationTest">
169-
<methods>
170-
<exclude name="testDisposerMethodsAreIntercepted"/>
171-
<exclude name="testInitializerMethodsNotIntercepted"/>
172-
<exclude name="testProducerMethodsAreIntercepted"/>
173-
<exclude name="testLifecycleCallbacksAreIntercepted"/>
174-
<exclude name="testObjectMethodsAreNotIntercepted"/>
175-
</methods>
176-
</class>
177-
<class name="org.jboss.cdi.tck.tests.lookup.byname.broken.prefix.ExpandedNamePrefix2Test">
178-
<methods>
179-
<exclude name="testDuplicateBeanNamePrefix"/>
180-
</methods>
181-
</class>
182148
<class name="org.jboss.cdi.tck.interceptors.tests.bindings.broken.InvalidTransitiveInterceptorBindingAnnotationsTest">
183149
<methods>
184150
<exclude name="testInterceptorBindingsWithConflictingAnnotationMembersNotOk"/>
@@ -214,11 +180,6 @@
214180
<exclude name="testDeploymentFails"/>
215181
</methods>
216182
</class>
217-
<class name="org.jboss.cdi.tck.tests.implementation.producer.method.broken.parameterizedTypeWithTypeParameter.ParametrizedReturnTypeWithTypeVariable02Test">
218-
<methods>
219-
<exclude name="testNonDependentScopedProducerMethodWithParameterizedTypeWithTypeVariable"/>
220-
</methods>
221-
</class>
222183
<class name="org.jboss.cdi.tck.tests.definition.scope.ScopeDefinitionTest">
223184
<methods>
224185
<exclude name="testScopeTypeHasCorrectTarget"/>
@@ -239,11 +200,6 @@
239200
<exclude name="testGetInjectableReferenceOnBeanManager"/>
240201
</methods>
241202
</class>
242-
<class name="org.jboss.cdi.tck.tests.interceptors.definition.broken.observer.async.InterceptorWithAsyncObserverMethodTest">
243-
<methods>
244-
<exclude name="testInterceptorWithAsyncObserverMethodNotOk"/>
245-
</methods>
246-
</class>
247203
<class name="org.jboss.cdi.tck.interceptors.tests.order.aroundInvoke.AroundInvokeOrderTest">
248204
<methods>
249205
<exclude name="testInvocationOrder"/>
@@ -281,11 +237,6 @@
281237
<exclude name="testDeploymentFails"/>
282238
</methods>
283239
</class>
284-
<class name="org.jboss.cdi.tck.tests.lookup.clientProxy.unproxyable.finalMethod.PublicFinalMethodNotProxyableTest">
285-
<methods>
286-
<exclude name="testClassWithPublicFinalMethodCannotBeProxied"/>
287-
</methods>
288-
</class>
289240
<class name="org.jboss.cdi.tck.tests.implementation.builtin.metadata.broken.typeparam.BeanTypeParamFieldTest">
290241
<methods>
291242
<exclude name="testDeploymentFails"/>
@@ -306,11 +257,6 @@
306257
<exclude name="testAbstractClassDeclaredInJavaNotDiscovered"/>
307258
</methods>
308259
</class>
309-
<class name="org.jboss.cdi.tck.tests.lookup.clientProxy.unproxyable.finalMethod.ProtectedFinalMethodNotProxyableTest">
310-
<methods>
311-
<exclude name="testClassWithPublicFinalMethodCannotBeProxied"/>
312-
</methods>
313-
</class>
314260
<class name="org.jboss.cdi.tck.interceptors.tests.bindings.aroundConstruct.ConstructorInterceptionTest">
315261
<methods>
316262
<exclude name="testTypeLevelAndConstructorLevelBinding"/>
@@ -382,27 +328,6 @@
382328
<exclude name="testMultipleLifecycleInterceptors"/>
383329
</methods>
384330
</class>
385-
<class name="org.jboss.cdi.tck.tests.lookup.byname.broken.prefix.NamePrefixTest">
386-
<methods>
387-
<exclude name="testDuplicateBeanNamePrefix"/>
388-
</methods>
389-
</class>
390-
<class name="org.jboss.cdi.tck.tests.lookup.clientProxy.unproxyable.finalMethod.NonPrivateNonStaticSuperclassMethodTest">
391-
<methods>
392-
<exclude name="testClassWithPublicFinalMethodCannotBeProxied"/>
393-
</methods>
394-
</class>
395-
<class name="org.jboss.cdi.tck.tests.implementation.simple.definition.dependentWithPublicField.DependentWithPublicFieldTest">
396-
<methods>
397-
<exclude name="testNonDependentScopedBeanCanNotHavePublicField"/>
398-
</methods>
399-
</class>
400-
<class name="org.jboss.cdi.tck.tests.event.observer.wildcardAndTypeVariable.ObserverMethodWithParametertizedTypeTest">
401-
<methods>
402-
<exclude name="testObserverMethodCanObserveArrayWildcard"/>
403-
<exclude name="testObserverMethodCanObserveArrayTypeVariable"/>
404-
</methods>
405-
</class>
406331
<class name="org.jboss.cdi.tck.tests.interceptors.definition.interceptorOrder.InterceptorOrderTest">
407332
<methods>
408333
<exclude name="testInterceptorsInvocationOrder"/>
@@ -433,11 +358,6 @@
433358
<exclude name="testEventFireThrowsExceptionIfEventObjectTypeContainsUnresovableTypeVariable"/>
434359
</methods>
435360
</class>
436-
<class name="org.jboss.cdi.tck.tests.lookup.clientProxy.unproxyable.finalMethod.PackagePrivateFinalMethodNotProxyableTest">
437-
<methods>
438-
<exclude name="testClassWithPublicFinalMethodCannotBeProxied"/>
439-
</methods>
440-
</class>
441361
<class name="org.jboss.cdi.tck.tests.interceptors.definition.InterceptorDefinitionTest">
442362
<methods>
443363
<exclude name="testInstanceOfInterceptorForEveryEnabledInterceptor"/>
@@ -449,27 +369,14 @@
449369
</class>
450370
<class name="org.jboss.cdi.tck.tests.inheritance.generics.MemberLevelInheritanceTest">
451371
<methods>
452-
<exclude name="testObserverResolution"/>
453-
<exclude name="testObserver"/>
454-
<exclude name="testInjectionPoint"/>
455372
<exclude name="testInjectionPointDefinition"/>
456373
</methods>
457374
</class>
458-
<class name="org.jboss.cdi.tck.tests.lookup.byname.broken.prefix.ExpandedNamePrefixTest">
459-
<methods>
460-
<exclude name="testDuplicateBeanNamePrefix"/>
461-
</methods>
462-
</class>
463375
<class name="org.jboss.cdi.tck.tests.definition.scope.inOtherBda.ScopeDefinedInOtherBDATest">
464376
<methods>
465377
<exclude name="testCustomScopeInOtherBDAisBeanDefiningAnnotation"/>
466378
</methods>
467379
</class>
468-
<class name="org.jboss.cdi.tck.tests.interceptors.definition.broken.observer.InterceptorWithObserverMethodTest">
469-
<methods>
470-
<exclude name="testInterceptorWithObserverMethodNotOk"/>
471-
</methods>
472-
</class>
473380
<class name="org.jboss.cdi.tck.tests.implementation.builtin.metadata.broken.injection.intercepted.InterceptedBeanFieldInjectionTest">
474381
<methods>
475382
<exclude name="testDeploymentFails"/>
@@ -508,11 +415,6 @@
508415
<exclude name="testDeploymentFails"/>
509416
</methods>
510417
</class>
511-
<class name="org.jboss.cdi.tck.tests.implementation.producer.field.definition.broken.typeVariable2.RequestScopedProducerFieldWithTypeVariableTest">
512-
<methods>
513-
<exclude name="testRequestScopedProducerFieldParameterizedWithTypeVariableNotAllowed"/>
514-
</methods>
515-
</class>
516418
<class name="org.jboss.cdi.tck.tests.event.observer.ObserverNotificationTest">
517419
<methods>
518420
<exclude name="testObserverMethodNotInvokedIfNoActiveContext"/>

0 commit comments

Comments
 (0)