Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-2614

Beans representing array types do not include Cloneable and Serializable in their type closures

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Not a Bug
    • 3.1.3.Final
    • None
    • Resolution
    • None

    Description

      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, should the return value of the producer method's Bean implementation's getTypeClosure() method include Cloneable (and Serializable)?

      I think it should.

      Cloneable.class.isAssignableFrom(Integer[].class) returns true because the JLS says it must.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ljnelson+github@gmail.com Laird Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: