I'm trying to create a generics class for de-/serializing via JAXB. When creating the JAXBContext
a class has to be passed in, but of course with a generic class, this is not known in advance.
So when I try this I get a compilation error of course.
public class ServerSerializing<T>
{
private JAXBContext mJAXBContext = null;
public JAXBContext getJAXBContext()
{
if(mJAXBContext == null)
mJAXBContext = JAXBContext.newInstance(T.class);
return mJAXBContext;
}
}
Results in:
Illegal class literal for the type parameter T
So is there a way this can be done with a generic?