Here you can find the source of unmarshaller(String xml, Class> T)
@SuppressWarnings("unchecked") public static <T> T unmarshaller(String xml, Class<?> T)
//package com.java2s; //License from project: Apache License import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.transform.stream.StreamSource; import java.io.*; public class Main { @SuppressWarnings("unchecked") public static <T> T unmarshaller(String xml, Class<?> T) { JAXBContext jc;/*from w ww .j ava 2 s.c om*/ Unmarshaller unmarshaller; Object o = null; try { jc = JAXBContext.newInstance(T); unmarshaller = jc.createUnmarshaller(); o = unmarshaller.unmarshal(new StreamSource(new StringReader(xml))); } catch (JAXBException e) { e.printStackTrace(); } return (T) o; } }