Here you can find the source of getMarshaller(Class> c)
private static Unmarshaller getMarshaller(Class<?> c) throws JAXBException
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Map; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; public class Main { private static Map<Class<?>, Unmarshaller> marshallerMap = new HashMap<>(); private static Unmarshaller getMarshaller(Class<?> c) throws JAXBException { if (marshallerMap.containsKey(c)) { return marshallerMap.get(c); } else {//from w ww .j ava 2s. c o m JAXBContext context = JAXBContext.newInstance(c); Unmarshaller unmarshaller = context.createUnmarshaller(); marshallerMap.put(c, unmarshaller); return unmarshaller; } } }