jaxb
  1. jaxb
  2. JAXB-884

JAnnotationArrayMember.annotations() is causing ClassCastException

    Details

    • Type: Bug Bug
    • Status: In Progress
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.5
    • Fix Version/s: None
    • Component/s: xjc
    • Labels:
      None

      Description

      JAnnotationArrayMember adds to values field annotations, which are not of type JAnnotationUse. Hence model causes ClassCastException when attempt is made to iterate this collection via JAnnotationArrayMember.annotations():

      // ann represents @XmlType class-level annotation.
      // ClassCastException here:
      for (JAnnotationUse ann : ((JAnnotationArrayMember) annotation.getAnnotationMembers().get("propOrder")).annotations()) {
      	...
      }
      

        Activity

        Hide
        Martin Grebac added a comment -

        Hi, thanks. Would you please add some more reproduction code here or the full exception trace to ease the fix/debugging? Thanks in advance.

        Show
        Martin Grebac added a comment - Hi, thanks. Would you please add some more reproduction code here or the full exception trace to ease the fix/debugging? Thanks in advance.
        Hide
        Dmitry Katsubo added a comment -

        I have caught this bug while working on code of jabx-xew plugin. In that line I refer JAXB-784, but the method code tries to overcome both of them.

        As I mentioned in issue description, JAnnotationArrayMember violates the casting by using explicitly @SuppressWarnings("unchecked"). For example JAnnotationStringValue which is added in line 76 is not of type JAnnotationUse.

        Show
        Dmitry Katsubo added a comment - I have caught this bug while working on code of jabx-xew plugin. In that line I refer JAXB-784 , but the method code tries to overcome both of them. As I mentioned in issue description, JAnnotationArrayMember violates the casting by using explicitly @SuppressWarnings("unchecked") . For example JAnnotationStringValue which is added in line 76 is not of type JAnnotationUse .
        Hide
        Martin Grebac added a comment -

        Either downgrade or mark metro2_3-exclude as this is not relevant to jaxb or metro - or perhaps easy to fix?

        Show
        Martin Grebac added a comment - Either downgrade or mark metro2_3-exclude as this is not relevant to jaxb or metro - or perhaps easy to fix?
        Hide
        Dmitry Katsubo added a comment -

        If xjc code model is part of JAXB, then why do you say it is not relevant?

        The issue can be fixed by changing the return type from Collection<JAnnotationUse> to Collection<JAnnotationValue> in JAnnotationArrayMember#annotations().

        Show
        Dmitry Katsubo added a comment - If xjc code model is part of JAXB, then why do you say it is not relevant? The issue can be fixed by changing the return type from Collection<JAnnotationUse> to Collection<JAnnotationValue> in JAnnotationArrayMember#annotations() .

          People

          • Assignee:
            Iaroslav Savytskyi
            Reporter:
            Dmitry Katsubo
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: