Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-448

Clarify autoboxing of arrays

    XMLWordPrintable

Details

    • Clarification
    • Resolution: Obsolete
    • Major
    • None
    • 1.2.Final
    • None
    • None

    Description

      Section 2.2.1:

      • A bean type may be an array type. Two array types are considered identical only if the element type is identical.
      • A bean type may be a primitive type. Primitive types are considered to be identical to their corresponding wrapper types in java.lang.

      When these two rules are combined, autoboxing of arrays is implied. For example, having type A defined as int[] and type B defined as Integer[] then:
      1) these two array types are considered identical as long as their element types (int and Integer) are identical
      2) int and Integer are considered identical (as primitive types are considered identical to java.lang wrapper types)

      Thus, A and B are considered identical.

      This is however in contrast to JLS where array autoboxing is not supported - you cannot do int[] foo = new Integer[0];

      It should therefore be clarified if array autoboxing is also unsupported in CDI or whether a CDI implementation should do the extra work to support this (e.g. allocating a new array and copying autboxed values over before injecting)

      Attachments

        Activity

          People

            Unassigned Unassigned
            rhn-engineering-jharting Jozef Hartinger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: