可能重复:
如何获取泛型类型 T 的类实例
模板的 T at
JAXBContext jaxbContext = JAXBContext.newInstance(T.class);
无法编译 T.class ,是否需要反射以及如何?
public void ConvertObjectToXML(String path, T bobject)
{
//Convert XML to Object
File file = new File(path);
JAXBContext jaxbContext = JAXBContext.newInstance(T.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
T customer2 = (T) jaxbUnmarshaller.unmarshal(file);
System.out.println(customer2);
}