Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6093

@XmlEnumValue annotation is lost from enum constant during compilation

    Details

      Description

      Consider the following enum, defined using Groovy (package and imports omitted):

      @XmlEnum
      enum GroovyEnum {
      @XmlEnumValue("good")
      BAD
      }

      When marshaling the enum as part of a larger object graph using JAXB, the expected behavior is that "good" will be the value of the generated XML element or attribute, as per the definition of the @XmlEnumValue annotation. In actuality, the value is marshaled as the enum constant name, "BAD".

      Further investigation indicates the @XmlEnumValue annotation cannot be found on GroovyEnum.BAD via reflection at runtime; it has been "lost" during compilation.

      Creating an identical (as much as permitted by syntax) enum in Java works as expected when used in a Groovy compilation.

      The attached Zip archive contains a set of files demonstrating the behavior, as driven by a JUnit 4 test case (JaxbMarshalingTest.groovy). GroovyEnum.groovy is the class being compiled incorrectly. Also included in the archive is JavaEnum.java; references to GroovyEnum can be trivially replaced with JavaEnum to demonstrate expected behavior.

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              jcttrll Jonathan Cottrill
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: