users@jaxb.java.net

Absence of XmlAccessorType from 2.1 to 2.2 not working

From: Luc <useyour.mind_at_gmail.com>
Date: Wed, 19 Dec 2012 10:08:25 +0100

Hello!

I've been using the JAXB bundled with JavaSE (2.1) to marshal/unmarshal
objects. These objects doesn't used the annotation @XmlAccessorType, only
@XmlElement on that fields / methods which had to be marshalled.
I use the javax.xml.bind.JAXB to do the un/marshalling.

In example:
public class ModelData {

private Model model;
private LinkedList<RegistrySample> samples;

public ModelData() {
samples = new LinkedList<RegistrySample>();
 }

public void add(RegistrySample sample) {
 samples.add(sample);
}

@XmlElement(name = "RSample")
public List<RegistrySample> getSamples() {
 return samples;
}

public void setSamples(List<RegistrySample> newSamples) {
 samples.clear();
if (newSamples != null) {
 samples.addAll(newSamples);
}
 }

public void removeLast() {
 samples.removeLast();
}

@XmlElement(name = "Model")
public Model getModel() {
 return model;
}

public void setModel(Model model) {
this.model = model;
 }

}
(None of the other objects is annotated with JAXB, only this class)

Now I am using a JavaEE container, which bundles JAXB 2.2, and the before
code doesn't work: it is correctly marshalled, but when unmarshalling the
object, the list is emtpy.

But annotating the ModelData class with
@XmlAccessorType(XmlAccessType.FIELD) and moving the
@XmlElementannotations to fields, works properly.

Is this change intentionally?

Thanks in advance,
--
Lucas