JiBX
  1. JiBX
  2. JIBX-182

unmarshalling collection into typed arraylist does not match arraylist type

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: JiBX 1.1.5
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:
      Windows 2k, Java 1.5.0_06, Oracle JDeveloper 10.1.3
    • Number of attachments :
      0

      Description

      If you have a collection unmarshalling into a typed ArrayList, and the binding file doesn't give the correct type, there is no error thrown either at bind compile time or at unmarshaling time.

      For example:

      class Template
      {
      enum days

      {MON, TUES, WED, THURS, FRI, SAT, SUN}

      ;
      ArrayList<days> activeDays;
      }

      and binding of

      <mapping name="template" class="Template">
      <collection field="activeDays">
      <value name="activeDays" type="java.lang.String" usage="optional"/>
      </collection>
      </mapping>

      And an xml file of:
      <template>
      <activeDays>MON</activeDays>
      </template>

      When this is unmarshalled, the activeDays array list has one element: A string "MON". rather than the enum element MON, as expected.

        Activity

        Hide
        Dennis Sosnoski added a comment -

        I can't really see this as a bug. Generic types are just a source code convenience to eliminate explicit casts (the casts are still there, they're just generated automatically by the compiler) and create the appearance of typed collections without the reality.

        With JiBX 2.0 source code generation this type of situation will show up as a compile-time error. Until then I don't see it as worth the effort to try to enforce generic types.

        Show
        Dennis Sosnoski added a comment - I can't really see this as a bug. Generic types are just a source code convenience to eliminate explicit casts (the casts are still there, they're just generated automatically by the compiler) and create the appearance of typed collections without the reality. With JiBX 2.0 source code generation this type of situation will show up as a compile-time error. Until then I don't see it as worth the effort to try to enforce generic types.

          People

          • Assignee:
            Dennis Sosnoski
            Reporter:
            Thomas Jones-Low
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: