Let's say I have a JAR xxx-core.jar with the following classes:
@XmlRootElement
@XmlSeeAlso({Imp1.class, Imp2.class})
public abstract class Abst {...}
@XmlRootElement
public class Imp1 extends Abst {...}
@XmlRootElement
public class Imp2 extends Abst {...}
public class Main {
@XmlElement
private Abst abst;
public static void load(File file) {
// unmarshal this
}
public void save(File file) {
// marshal this
}
}
So far, so good. Main can be marshalled and unmarshalled, and the correct implementation of Abst is used.
Now, what happens when somebody else comes along and creates another project xxx-extension.jar that uses xxx-core.jar, but contains the following class:
@XmlRootElement
public class ExtensionImp extends Abst {...}
and assigns an instance of this new implementation to Main's member variable? Since it's not explicitly given in the XmlSeeAlso annotation, how can I make sure that ExtensionImp will be correctly marshalled/unmarshalled? (I've played with the class list in JAXBContext.newInstance(), but that doesn't seem to solve the problem.)