_______________________________________________Hi,
I was trying to test @XmlSeeAlso, which is intended to work as such:
@XmlSeeAlso(SubType.class)
public class SuperType {}
public class SubType extends SuperType {}
@Path("/")
public class Controller {
@GET
public SuperType get() {
return new SubType();
}
}
So that the marshaller knows to serialise it as a SubType instead of the declared SuperType. But I can't get the JAXBXmlSeeAlsoProvider provider to be invoked, because in ServerResponseWriter we do this:
Class type = jaxrsResponse.getEntityClass();
Type generic = jaxrsResponse.getGenericType();MessageBodyWriter writer = providerFactory.getMessageBodyWriter(
type, generic, annotations, mt);
And `type` is obtained by doing entity.getClass() (so it is SubType) while `generic` comes from the method declaration (it is SuperType). And
JAXBXmlSeeAlsoProvider.isReadWritable() uses the Class to ask if it has the @XmlSeeAlso annotation (it does not, because it's the SubType class).All in all, it works, because we fall back to not needing @XmlSeeAlso since the class points to the subtype, but the generic type will point to the superclass and so they're really two different types.
Is this a bug?
resteasy-dev mailing list
resteasy-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/resteasy-dev