Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 359127

Summary: XmlJavaTypeAdapter requires specified class extend XmlAdapter directly
Product: z_Archived Reporter: Paul Fullbright <paul.fullbright>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: blaise.doughan, martin.grebac, rick.barkhouse
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Test Case
none
Patch - code changes - 2.5
none
Patch - test changes - 2.5
none
Patch - code changes - 2.5
none
Patch - test and code changes - 2.3 none

Description Paul Fullbright CLA 2011-09-27 14:49:06 EDT
example:

@XmlRootElement
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class Root {
	
	@XmlJavaTypeAdapter(FooAdapter.class)
	protected Foo foo;
}

public class Foo {}

@XmlAccessorType(XmlAccessType.FIELD)
public class Bar {
	
	protected String bar = "baz";
}

public class FooAdapter extends SuperFooAdapter {}

public class SuperFooAdapter extends XmlAdapter<Bar, Foo> {

	@Override
	public Foo unmarshal(Bar v) throws Exception {
		return new Foo();
	}

	@Override
	public Bar marshal(Foo v) throws Exception {
		return new Bar();
	}
}


This will marshal model like:
<root>
   <foo>adapt.Bar@1309025</foo>
</root>

whereas RI: will marshal like:
<root>
    <foo>
        <bar>baz</bar>
    </foo>
</root>


(Also, debugging reveals that SuperFooAdapter is not queried for marshal methods.)
Comment 1 Rick Barkhouse CLA 2012-03-01 11:27:39 EST
Created attachment 211895 [details]
Test Case
Comment 2 Rick Barkhouse CLA 2012-03-01 12:09:20 EST
It looks like this has already been fixed in another 2.3 transaction.  I have confirmed that the adapter superclass is hit during marshal, and that the output is as expected, not a toString().

Added a test case to guard against a regression.
Comment 3 Blaise Doughan CLA 2012-05-23 14:21:25 EDT
The problem occurs if the JAXBContext is created with only the Root class.

    Class[] classes = new Class[] {Root.class};
Comment 4 Rick Barkhouse CLA 2012-05-24 14:32:59 EDT
Created attachment 216219 [details]
Patch - code changes - 2.5
Comment 5 Rick Barkhouse CLA 2012-05-24 14:33:17 EDT
Created attachment 216220 [details]
Patch - test changes - 2.5
Comment 6 Rick Barkhouse CLA 2012-05-24 14:45:10 EDT
Created attachment 216224 [details]
Patch - code changes - 2.5
Comment 7 Rick Barkhouse CLA 2012-05-25 10:11:33 EDT
*** Bug 373106 has been marked as a duplicate of this bug. ***
Comment 8 Rick Barkhouse CLA 2012-05-25 10:13:59 EDT
Fixed and checked into 2.4, rev. 11492
Comment 9 Rick Barkhouse CLA 2012-05-25 10:35:33 EDT
Checked into 2.5, rev. 11494
Comment 10 Rick Barkhouse CLA 2012-05-25 12:23:13 EDT
Created attachment 216300 [details]
Patch - test and code changes - 2.3
Comment 11 Rick Barkhouse CLA 2012-05-25 12:38:12 EDT
Fixed and checked into 2.3.3, rev. 11501
Comment 12 Eclipse Webmaster CLA 2022-06-09 10:25:31 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink