[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Mark Struberg created an issue CDI TCK / CDITCK-591 AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules Issue Type: Bug Affects Versions: 2.0.0.Final Assignee: Tomas Remes Components: Tests Created: 15/Jun/17 2:53 PM Priority: Major Reporter: Mark Struberg This test has actually quite a few shortcomings. It modifies the AnnotatedType for the createVegetables producer method to have a TypeClosure of {Carrot.class} (Carrot implements Vegetables). The problem is that this violates the rules for type closures (2.2). Type closures is by default the bean type and all it's interfaces, parent classes, etc. One can further restrict those classes via @Typed or by modifying the AnnotatedType. But it imo not allowed to have a Type in the TypeClosures which is not contained in e.g. the return type of a producer method. In the TCK test the producer method returns Vegetables and the test modifies it to a type closure of {Carrot.class} . So what happens if the producer method returns a new Tomato() ? The other point is that for matching producers and disposers the type closures is not taken into account as per the spec, but only the return type and the type of the dispose parameter. See 3.4.1. Disposed parameter of a disposer method Each disposer method must have exactly one disposed parameter, of the same type as the corresponding producer method return type or producer field type.
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Matej Novotny commented on CDITCK-591 Re: AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules I dare disagree, from my perspective, you are not restricting the set (you are not using @Typed at all btw) - you are replacing whole underlying AT with another one. Regarding spec, 2.2 and 3.2.1 basically says that unrestricted set of bean types is based on return type (and follows up with a precise definition how to derive that from interface/primitive/class). So yes, that holds true, until you start changing the method which is the case here. You basically take the existing one as a template, alter it and put in there instead. As with many custom things in extensions, you might break your code easily (e.g. your example with Tomato) but that's your problem, really. I think you are enforcing rules which aren't implied by spec and might be unnecessarily strict. Ofc we both might be wrong, so it would be nice if we get to hear some more opinions Add Comment This message was sent by Atlassian JIRA (v7.2.3#72005-sha1:73be91d) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Mark Struberg commented on CDITCK-591 Re: AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules I think we have to look at 2 different pieces. The sentence quoted above regarding Disposer-Producer matching requires that the exact same return type. Not Type Closures, it explicitly says "return type". This rule is violated by the example The other point which is imo violated is that the type closure must only be a sub section of the original types. Let's look at the following sample: @ApplicationScoped public class Dog extends Mammal (extends Animal) {..} Now what if you change the Type Closure to 'Poodle'? This will simply blow up. I also don't see the practical use of the hack in this test. If you want to have automatic support for @Inject Tomato and @Inject Carrot then you can do this via collecting the info in ProcessInjectionPoint and register a custom Bean for each type. Add Comment This message was sent by Atlassian JIRA (v7.2.3#72005-sha1:73be91d)
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Mark Struberg edited a comment on CDITCK-591 Re: AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules I think we have to look at 2 different pieces. The sentence quoted above regarding Disposer-Producer matching requires that the exact same *return type*. Not Type Closures, it _explicitly_ says "return type".This rule is violated by the exampleThe other point which is imo violated is that the type closure must only be a sub section of the original types. Let's look at the following sample:{code:java}@ApplicationScopedpublic class Dog extends Mammal (extends Animal) {..}{code}Now what if you change the Type Closure to 'Poodle'?This will simply blow up.I also don't see the practical use of the hack in this test.If you want to have automatic support for @Inject Tomato and @Inject Carrot then you can do this via collecting the info in ProcessInjectionPoint and register a custom Bean for each type. Add Comment This message was sent by Atlassian JIRA (v7.2.3#72005-sha1:73be91d) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Tomas Remes commented on CDITCK-591 Re: AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules I think we have to look at 2 different pieces. The sentence quoted above regarding Disposer-Producer matching requires the exact same return type. Not Type Closures, it explicitly says "return type". This rule is violated by the example I don't think this is violated in the test. The Grocery#createVegetable (wrapped by new AT - GroceryWrapper) returns type Carrot which reflects the corresponding assertion which states: the container must call Annotated.getTypeClosure() to determine the bean types of any kind of bean, The related disposal method has parameter with type Carrot as well (again it reflects corresponding assertion wrt Annotated.getBaseType()). I can't see anything wrong in this test. The other point which is imo violated is that the type closure must only be a sub section of the original types. Where is it defined? The test doesn't restrict any type closure set of any existing bean. It just creates custom AT which declares the given set of types. TCK is not very often about practical use but rather about testing spec assertions which sometimes mean to test real corner cases. Add Comment This message was sent by Atlassian JIRA (v7.2.3#72005-sha1:73be91d)
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Mark Struberg commented on CDITCK-591 Re: AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules Tomas Remes it would not violate the first restriction if it would return Carrot in getBaseType() ! But the wrapped AT violates this requirement by having a getTypeClosures() contain a class which is not contained in the the fully transitive type closure of getBaseType(). > The related disposal method has parameter with type Carrot Again, the spec paragraph clearly does not refer to type closures but to "return type". That's some different term and relates to getBaseType() in the AT afaict. Add Comment This message was sent by Atlassian JIRA (v7.2.3#72005-sha1:73be91d) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Tomas Remes commented on CDITCK-591 Re: AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules Well I don't think there is a need to override the getBaseType method for the producer method createVegetable because the assertion for getBaseType states: the container must call Annotated.getBaseType() to determine the type of an injection point, event parameter or disposed parameter, This is simply not the case since there is no IP, event parameter nor disposed parameter. Antoine Sabot-Durand Can you please comment on this one? Add Comment This message was sent by Atlassian JIRA (v7.2.3#72005-sha1:73be91d) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Antoine Sabot-Durand commented on CDITCK-591 Re: AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules Mark StrubergI think there's a misunderstanding. Your point regarding type closure is true in standard metadata discovery and creation (i.e. done thru class scanning). The best proof is that If you read section 2 carefully, you'll see that its mentions "bean class" from time to time. These rules don't apply when it comes to synthetic metadata. You can create a custom bean with a totally "inconsistent" types set from section 2 perspective. This is often done when you want to provide powerful features like type conversion. Other rules described in chapter 2 can be broken when defining synthetic metadata. For instance you can create custom bean without @Any in its qualifiers set while chapter 2 says that all beans have it. So why should we forbid in synthetic AnnotatedType what we allow in synthetic beans? Add Comment This message was sent by Atlassian JIRA (v7.2.3#72005-sha1:73be91d) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Tomas Remes resolved as Rejected CDI TCK / CDITCK-591 AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules Change By: Tomas Remes Status: Open Resolved Resolution: Rejected Add Comment This message was sent by Atlassian JIRA (v7.2.3#72005-sha1:73be91d) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Mark Struberg commented on CDITCK-591 Re: AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules Antoine Sabot-Durand I did not question that one can create inconsistent Beans. Nonetheless the rules for producer/disposal methods DO also apply to them. And if the 'return type' (which in the AT boils down to getBaseType) does not match, then the disposer and producer does not fit together. And this is exactly the case with this test - which renders the test as it currently is invalid. Add Comment This message was sent by Atlassian JIRA (v7.2.3#72005-sha1:73be91d) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Mark Struberg reopened an issue CDI TCK / CDITCK-591 AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules Change By: Mark Struberg Resolution: Rejected Status: Resolved Reopened Add Comment This message was sent by Atlassian JIRA (v7.2.3#72005-sha1:73be91d) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Tomas Remes assigned an issue to Unassigned CDI TCK / CDITCK-591 AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules Change By: Tomas Remes Assignee: Tomas Remes Add Comment This message was sent by Atlassian JIRA (v7.2.3#72005-sha1:73be91d) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (CDITCK-591) AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules
Title: Message Title Matej Novotny resolved as Rejected Looks like there are two problems which were discussed here. I'm going to reject this issue, but here is my reasoning why I'm doing so (apart from the fact that both, CDI TCK lead and CDI spec lead, agreed on the test being correct): Firstly, it was disputed that the test restricts the types of the producer in an incorrect way. The test itself does not make use of @Typed to restrict it, it instead replaces the whole AT. The method itself returns Carrot as it is and we only swapped the getTypeClosure() call, which is used to determine bean types of any kind of bean. Hence the producer still makes sense. One of the relevant parts of spec says: ...the container must: call Annotated.getBaseType() to determine the type of an injection point, event parameter or disposed parameter, call Annotated.getTypeClosure() to determine the bean types of any kind of bean, And secondly, in regards to Producer-Disposer matching problem - according to specification, the Annotated interface: getTypeClosure() returns all types to which the base type should be considered assignable. Changing this has direct effect on bean's assignability to injection points but also to disposer methods. This basically says that for every IP, you look at the getBaseType() and then try to match it against all beans' getClosureType() to see if you get a type match. Test changes getTypeClosure() for createVegetable() producer method to Carrot. The disposer method is altered in a similar way, via getBaseType() - again to Carrot. Hence you are now matching disposer's getBaseType() (Carrot) to producer's getTypeClosure() (Carrot) which is totally valid. I reckon that the bits and pieces of important information are scattered throughout the spec but putting them together, I can only see this test as valid, although not a common case for sure. CDI TCK / CDITCK-591 AlternativeMetadataTest createVegetables and destroyVegetables violate Type Closure rules Change By: Matej Novotny Status: Reopened Resolved