javaee / metro-jax-ws

https://javaee.github.io/metro-jax-ws/
Other
132 stars 68 forks source link

JAXB marshaller ignores XmlAccessType.NONE #1186

Open glassfishrobot opened 8 years ago

glassfishrobot commented 8 years ago

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]

glassfishrobot commented 8 years ago

Reported by niels.bertram

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAX_WS-1186