Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdi-dev] TCK: org.jboss.cdi.tck.tests.definition.bean.types.illegal.BeanTypesWithIllegalTypeTest

Hi,

On Tue, Feb 28, 2023 at 11:58 PM David Blevins <dblevins@xxxxxxxxxxxxx> wrote:
Just to help me understand how we view parameterized types that have wildcards.


Which of these producers are valid?

    @Produces
    public Consumer<? extends Number> assignableToNumber() {
        return null;
    }

"If a producer method return type contains a wildcard type parameter or is an array type whose component type contains a wildcard type parameter, the container automatically detects the problem and treats it as a definition error."

Similar provision exists for producer fields. For managed beans, there's no need for such a rule, because 1. you can't extend or implement a parameterized type whose type argument is a wildcard type, 2. a parameterized type that contains a wildcard is not a legal bean type per https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0.html#legal_bean_types and hence would be removed from the set of bean types anyway.

    @Produces
    public Consumer<Number> number() {
        return null;
    }

Valid.
 
Which of these observers are valid?

    public void assignableToNumber(@Observes Consumer<? extends Number> assignableToNumber) {
    }

    public void number(@Observes Consumer<Number> number) {
    }

Both are valid.

Note that if you fire `new Consumer<Number>() { ... }`, both observers will be notified, as specified in https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0.html#observer_resolution.
 
Which of these injection points are valid?

    @Inject
    Consumer<? extends Number> assignableToNumber;

    @Inject
    Consumer<Number> number;

Both are valid.

Note that if there's a bean with type `Consumer<Number>` among its bean types, it will be injected into both injection points, as specified in https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0.html#typesafe_resolution

Hope that helps.

LT
 


-David

On Feb 28, 2023, at 12:08 AM, Ladislav Thon <lthon@xxxxxxxxxx> wrote:

Hi,

all tests in the TCK should "say what part of the spec" they test using the `@SpecAssertion` annotation. If there's a test without this annotation, that's a bug.

Now, this test _does_ have `@SpecAssertion`s, so you can find which part of the spec they test in the tck-audit-*.xml files. For example, `beanSetOfBeanTypesContainsOnlyLegalTypes` verifies that "The resulting set of bean types for a managed bean consists only of legal bean types, all other types are removed from the set of bean types."

What are legal bean types (and what are illegal bean types) is defined here: https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0.html#legal_bean_types

LT

On Tue, Feb 28, 2023 at 12:53 AM Jean-Louis Monteiro <jlmonteiro@xxxxxxxxxxxxx> wrote:
Hi,

This sounds like a negative test, but it does not say what part of the spec or what it's supposed to do.

Can someone explain to me please?

Best

_______________________________________________
cdi-dev mailing list
cdi-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdi-dev
_______________________________________________
cdi-dev mailing list
cdi-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdi-dev

_______________________________________________
cdi-dev mailing list
cdi-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdi-dev

Back to the top