users@jaxb.java.net

Re: JAXBElement: afterUnmarshal callback parent incorrect

From: Jason Harrop <jharrop_at_gmail.com>
Date: Wed, 29 Sep 2010 23:24:09 +1000

Hi

Well, we use getParent(0 extensively via the parent pointer plugin
from jaxb2 commons.

Its just that in the case of a JAXBElement, it doesn't work, and the
reason it doesn't work is because JAXB is passing the wrong
information in to afterUnmarshal

Yes, I think you could get the parent using Binder (although it has
its own problems - see bug 459), but it would be nicer if
afterUnmarshal worked as advertised.

Re the javadoc: "This method is invoked after all the properties
(except IDREF) are unmarshalled into target, but before target is set
into its parent object." , my reading is that this is just telling you
*when* the method is invoked. In other words, the target is told what
its parent is (via the callback), and after that, it is made a member
of the parent. Which would be fine.

thanks .. Jason




On Wed, Sep 29, 2010 at 11:11 PM, Wolfgang Laun <wolfgang.laun_at_gmail.com> wrote:
> Hmm, do you think that "tree climbing" could be achieved if you do get
> the real XML parent? Reading the Javadoc of afterUnmarshal indicates two
> serious obstacles: IDREFs aren't expanded yet, and the child isn't set into
> its parent.
>
> Possibly you have raised a valid point - but I'd say for the wrong reason?!
>
> -W
>
>
> On 29 September 2010 03:09, Jason Harrop <jason_at_plutext.org> wrote:
>> Hi guys
>>
>> If finding that if an XML element unmarshalls as a JAXBElement, then
>> in the afterUnmarshal callback for the relevant class, the parent
>> passed in is wrong.
>>
>> The parent should be, well, the parent.  Instead, it is a JAXBElement
>> (which wraps a copy of the child).  The result is that you can't climb
>> the tree from anything wrapped in a JAXBElement.
>>
>> I did log this with Oracle a week ago, but haven't heard anything back.
>>
>> Thoughts (apart from providing a test case)?
>>
>> .. Jason
>>
>>
>>
>>
>> ---------- Forwarded message ----------
>> From: IncidentDaemon_at_sun.com <IncidentDaemon_at_sun.com>
>> Date: Tue, Sep 21, 2010 at 3:13 PM
>> Subject: Your Report (Review ID: 1874905) - JAXB 2.x afterUnmarshal
>> callback parent incorrect
>> To: jason_at_plutext.org
>>
>>
>>
>> ---------------------------------------------------------------
>>
>>
>> Date Created: Mon Sep 20 23:13:14 MDT 2010
>> Type:        bug
>> Customer Name:   Jason Harrop
>> Customer Email:  jason_at_plutext.org
>> SDN ID:
>> status:      Waiting
>> Category:    jaxb-xsd
>> Subcategory: runtime
>> Company:     Plutext
>> release:     1.0.4
>> hardware:    x64
>> OSversion:   windows_7
>> priority:    4
>> Synopsis:    JAXB 2.x afterUnmarshal callback parent incorrect
>> Description:
>>  FULL PRODUCT VERSION :
>> JAXB 2.x
>>
>> ADDITIONAL OS VERSION INFORMATION :
>> All os
>>
>> EXTRA RELEVANT SYSTEM CONFIGURATION :
>> irrelevant
>>
>> A DESCRIPTION OF THE PROBLEM :
>> If an element unmarshalls as a JAXBElement, then in the afterUnmarshal
>> callback, the parent passed in is wrong.
>>
>> The parent should be the parent.  Instead, it is a JAXBElement which
>> looks like the child.
>>
>> STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
>> Unmarshall something which results in a JAXBElement, and look at its
>> parent by implementing the afterUnmarshall callback..
>>
>> EXPECTED VERSUS ACTUAL BEHAVIOR :
>> EXPECTED -
>> Expected the parent value to match the parent XML node.
>> ACTUAL -
>> The parent value matched the child.
>>
>> REPRODUCIBILITY :
>> This bug can be reproduced always.
>> workaround:
>> comments:    (company - Plutext , email - jason_at_plutext.org)
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>