Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.1.2
-
OS: Windows 7, Windows XP
JVM: 1.7.0_17 (Oracle)
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.