Hi,
the reason is an incomplete fix in issue 488 made to ease
compatibility between JDK6u releases. It should've been made with a
property switch in unmarshaller. Unfortunately this piece does not seem
covered by TCK because the spec itself does not define any behaviour
according to set method. We'll fix the default behaviour to conform to
the spec, and reopen 488 to finish the fix by adding a switch,
MartiNG
On 2/18/13 4:02 PM, Mukundha Madhavan wrote:
> Hello Folks,
>
> We are migrating our project to JDK7, we ran into an issue with JAXB
> in JDK7.
>
> The issue is for the sample class below,
>
> @XmlRootElement(name="a")
> public class TestBean {
> private List<String> b ;
> @XmlElement(name="b")
> public List<String> getB(){
> return b ;
> }
> public void setB(List<String> 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
>
> Can someone pls explain me why this is changed? I do not understand
> why bean is called with the setter with the same reference?
>
> Thanks for your help! Let me know if you need any additional information
>
> Cheers!
> Mukundha
>
--
Martin Grebac, SW Engineering Manager (Metro/JAXWS/JAXB RI)
Oracle Czech, Prague
http://blogs.oracle.com/mgrebac