1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/SingleMapNodeProperty.java Thu Oct 31 12:36:20 2013 -0700 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/SingleMapNodeProperty.java Fri Nov 22 21:11:19 2013 +0100 1.3 @@ -42,7 +42,6 @@ 1.4 import com.sun.xml.internal.bind.v2.ClassFactory; 1.5 import com.sun.xml.internal.bind.v2.util.QNameMap; 1.6 import com.sun.xml.internal.bind.v2.model.core.PropertyKind; 1.7 -import com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator; 1.8 import com.sun.xml.internal.bind.v2.model.runtime.RuntimeMapPropertyInfo; 1.9 import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl; 1.10 import com.sun.xml.internal.bind.v2.runtime.JaxBeanInfo; 1.11 @@ -98,7 +97,8 @@ 1.12 this.valueBeanInfo = context.getOrCreate(prop.getValueType()); 1.13 1.14 // infer the implementation class 1.15 - Class<ValueT> sig = ReflectionNavigator.REFLECTION.erasure(prop.getRawType()); 1.16 + //noinspection unchecked 1.17 + Class<ValueT> sig = (Class<ValueT>) Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType()); 1.18 mapImplClass = ClassFactory.inferImplClass(sig,knownImplClasses); 1.19 // TODO: error check for mapImplClass==null 1.20 // what is the error reporting path for this part of the code? 1.21 @@ -140,23 +140,22 @@ 1.22 */ 1.23 private final Loader itemsLoader = new Loader(false) { 1.24 1.25 - private ThreadLocal<Stack<BeanT>> target = new ThreadLocal<Stack<BeanT>>(); 1.26 - private ThreadLocal<Stack<ValueT>> map = new ThreadLocal<Stack<ValueT>>(); 1.27 + private ThreadLocal<BeanT> target = new ThreadLocal<BeanT>(); 1.28 + private ThreadLocal<ValueT> map = new ThreadLocal<ValueT>(); 1.29 + private int depthCounter = 0; // needed to clean ThreadLocals 1.30 1.31 @Override 1.32 public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { 1.33 // create or obtain the Map object 1.34 try { 1.35 - BeanT target = (BeanT) state.prev.target; 1.36 - ValueT mapValue = acc.get(target); 1.37 - if(mapValue == null) 1.38 - mapValue = ClassFactory.create(mapImplClass); 1.39 - else 1.40 - mapValue.clear(); 1.41 - 1.42 - Stack.push(this.target, target); 1.43 - Stack.push(map, mapValue); 1.44 - state.target = mapValue; 1.45 + target.set((BeanT)state.prev.target); 1.46 + map.set(acc.get(target.get())); 1.47 + depthCounter++; 1.48 + if(map.get() == null) { 1.49 + map.set(ClassFactory.create(mapImplClass)); 1.50 + } 1.51 + map.get().clear(); 1.52 + state.target = map.get(); 1.53 } catch (AccessorException e) { 1.54 // recover from error by setting a dummy Map that receives and discards the values 1.55 handleGenericException(e,true); 1.56 @@ -168,7 +167,11 @@ 1.57 public void leaveElement(State state, TagName ea) throws SAXException { 1.58 super.leaveElement(state, ea); 1.59 try { 1.60 - acc.set(Stack.pop(target), Stack.pop(map)); 1.61 + acc.set(target.get(), map.get()); 1.62 + if (--depthCounter == 0) { 1.63 + target.remove(); 1.64 + map.remove(); 1.65 + } 1.66 } catch (AccessorException ex) { 1.67 handleGenericException(ex,true); 1.68 } 1.69 @@ -286,36 +289,4 @@ 1.70 return acc; 1.71 return null; 1.72 } 1.73 - 1.74 - private static final class Stack<T> { 1.75 - private Stack<T> parent; 1.76 - private T value; 1.77 - 1.78 - private Stack(Stack<T> parent, T value) { 1.79 - this.parent = parent; 1.80 - this.value = value; 1.81 - } 1.82 - 1.83 - private Stack(T value) { 1.84 - this.value = value; 1.85 - } 1.86 - 1.87 - private static <T> void push(ThreadLocal<Stack<T>> holder, T value) { 1.88 - Stack<T> parent = holder.get(); 1.89 - if (parent == null) 1.90 - holder.set(new Stack<T>(value)); 1.91 - else 1.92 - holder.set(new Stack<T>(parent, value)); 1.93 - } 1.94 - 1.95 - private static <T> T pop(ThreadLocal<Stack<T>> holder) { 1.96 - Stack<T> current = holder.get(); 1.97 - if (current.parent == null) 1.98 - holder.remove(); 1.99 - else 1.100 - holder.set(current.parent); 1.101 - return current.value; 1.102 - } 1.103 - 1.104 - } 1.105 }