jaxb-ri
jaxb-ri copied to clipboard
JAXB marshaller ignores XmlAccessType.NONE
Hi there,
I recently recompiled some code on Java 8 and found that JAXB does not yield to the ({XmlAccessType.NONE}} anymore.
package xml.exception;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class SimpleException extends Exception {
private String id;
public SimpleException() {
}
public SimpleException(String id) {
this.id = id;
}
public static void main(String[] args) throws Exception {
JAXBContext jc = JAXBContext.newInstance(SimpleException.class);
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
SimpleException e = new SimpleException("12");
m.marshal(e, System.out);
}
@XmlAttribute
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
On Java 7 this used to work and produced this:
<simpleException id="12"/>
but instead on JAva 8 it produces this:
<simpleException id="12">
<stackTrace/>
<stackTrace/>
<stackTrace/>
<stackTrace/>
<stackTrace/>
<stackTrace/>
</simpleException>
Has anyone come across this problem?
Affected Versions
[2.2.10]
Source: https://github.com/javaee/metro-jax-ws/issues/1186 Author: glassfishrobot