I have a model that consists of an interface with one annotated property, and a concrete implementor that does not re-annotate the implementation of that property. Why doesn't this unmarshal correctly (using MOXy 2.5.0)? I get a correctly constructed object, but the property is never bound to the XML:
<!-- XML -->
<InterfaceImpl id="5150" />
/**
* Annotated interface
*/
@XmlRootElement(name="IInterface")
public interface IInterface
{
@XmlAttribute(name="id")
public void setId(int id);
}
/**
* Concrete implementor
*/
@XmlRootElement(name="InterfaceImpl")
public class InterfaceImpl implements IInterface
{
private int m_id = -1;
@Override
public void setId(int id)
{
m_id = id;
}
}
/**
* Unmarshal code
*/
File f = new File("src\\resources\\Interface.xml");
JAXBContext context = JAXBContext.newInstance(MY_PATH);
Unmarshaller u = context.createUnmarshaller();
InterfaceImpl i = (InterfaceImpl)u.unmarshal(f);
If I change IInterface to an abstract class, it works correctly - shouldn't abstract classes and interfaces be handled the same way? Is this expected behavior, or a known issue?
Thanks!