JAXB differences in JDK 7 in com/sun/xml/internal/bind/v2/runtime/reflect/Lister.java#Lister.CollectionLister.endPacking · Issue #948 · javaee/jaxb-v2 (original) (raw)

Hello Folks,

The issue is for the sample class below,

@XmlRootElement(name="a")
public class TestBean {
private List b ;
@xmlelement(name="b")
public List getB()

{ return b ; }

public void setB(List b)

{ this.b = b ; }

}

Order of method invocation in JDK 6 was
1. getB() - b was null
2. setB() - b was empty

But the Order of method invocation in JDK 7 is,
1. getB() - b was null
2. setB() - b was empty
3. setB() - (this.b==b) is true and b is my list full of elements

We are running into an issue because of this behavior.

With debug in JDK 6 and JDK 7 i guess, we found the code causing this changed behavior.

refer to endPackaging method on CollectionLister,

this is the JDK 6 source code,
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/com/sun/xml/internal/bind/v2/runtime/reflect/Lister.java#Lister.CollectionLister.endPacking%28java.util.Collection%2Cjava.lang.Object%2Ccom.sun.xml.internal.bind.v2.runtime.reflect.Accessor%29

this is the JDK 7 source code,
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/com/sun/xml/internal/bind/v2/runtime/reflect/Lister.java#Lister.CollectionLister.startPacking%28java.lang.Object%2Ccom.sun.xml.internal.bind.v2.runtime.reflect.Accessor%29

I am not sure why bean is called with the setter with the same reference, can someone pls help me understand this change?

Thanks for your help! Let me know if you need any additional information

Cheers!

Environment

JDK 7

Affected Versions

[2.2.6]