[weld-issues] [JBoss JIRA] (WELD-2614) Beans representing array types do not include Cloneable and Serializable in their type closures
Title: Message Title Laird Nelson created an issue Weld / WELD-2614 Beans representing array types do not include Cloneable and Serializable in their type closures Issue Type: Bug Affects Versions: 3.1.3.Final Assignee: Unassigned Components: Resolution Created: 01/Mar/20 1:23 PM Priority: Minor Reporter: Laird Nelson I am not sure whether this is a bug or a feature enhancement. When a bean of any kind reports its type closure, it ends up doing so using its getTypeClosure() method. The CDI specification says somewhere in section 11.4: "getTypeClosure() returns all types to which the base type should be considered assignable." Note the very careful wording here: it doesn't mention superclasses or interfaces, just assignability. Now consider an injection point like this: @Inject private Cloneable foo; And a producer method like this: @Produces private static Integer[] makeIntegers() { return new Integer[]{42}; } Leaving aside whether this would be ambiguous (this would be a truly stupid injection point), should the producer method's return type (Integer[].class, one of its bean types) be considered assignable to an injection point of type Cloneable? Or, more precisely,
[weld-issues] [JBoss JIRA] (WELD-2614) Beans representing array types do not include Cloneable and Serializable in their type closures
Title: Message Title Laird Nelson updated an issue Weld / WELD-2614 Beans representing array types do not include Cloneable and Serializable in their type closures Change By: Laird Nelson I am not sure whether this is a bug or a feature enhancement.When a bean of any kind reports its type closure, it ends up doing so using its {{getTypeClosure()}} method. The CDI specification says somewhere in section 11.4:"{{getTypeClosure()}} returns all types *to which the base type should be considered assignable*."Note the very careful wording here: it doesn't mention superclasses or interfaces, just assignability.Now consider an injection point like this:{code}@Injectprivate Cloneable foo;{code}And a producer method like this:{code}@Producesprivate static Integer[] makeIntegers() { return new Integer[]{42};}{code}*Leaving aside whether this would be ambiguous* (this would be a truly stupid injection point), should the producer method's return type ({{Integer[].class}}, one of its bean types) be considered assignable to an injection point of type {{Cloneable}}?Or, more precisely, should the return value of the producer method's {{Bean}} implementation's {{getTypeClosure()}} method include {{Cloneable}} (and {{Serializable}})?I think it should. An array type does not have {{Cloneable }} in its superclass hierarchy (obviously) or its implemented interfaces, but {{Cloneable .class.isAssignableFrom(Integer[].class)}} returns {{true}} because the JLS [says it must|https://docs.oracle.com/javase/specs/jls/se13/html/jls-4.html#jls-4.10.3]. Add Comment
[weld-issues] [JBoss JIRA] (WELD-2614) Beans representing array types do not include Cloneable and Serializable in their type closures
Title: Message Title Martin Kouba commented on WELD-2614 Re: Beans representing array types do not include Cloneable and Serializable in their type closures No, it shouldn't. The CDI spec is clear that the set of bean types of a producer method "exactly two types: the method return type and java.lang.Object". Note that CDI defines its own assignability rules. Feel free co create a spec issue if you think it's a major issue that requires clarification. Add Comment This message was sent by Atlassian Jira (v7.13.8#713008-sha1:1606a5c) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues