@SuppressWarnings({ "unchecked" })
private Object readSortedMapData(final boolean unshared, int cacheIdx, final int len, final SortedMap target, final boolean discardMissing) throws ClassNotFoundException, IOException {
final ArrayList<Object> instanceCache = this.instanceCache;
final int idx;
final FlatNavigableMap filler = new FlatNavigableMap(target.comparator());
if (cacheIdx == -1) {
idx = instanceCache.size();
instanceCache.add(target);
} else {
idx = cacheIdx;
instanceCache.set(idx, target);
}
for (int i = 0; i < len; i ++) {
filler.put(doReadMapObject(false, i, len, true, discardMissing), doReadMapObject(false, i, len, false, discardMissing));
}
// should install entries in order, bypassing any circular ref issues, unless the map is mutated during deserialize of one of its elements
target.putAll(filler);
final Object resolvedObject = objectResolver.readResolve(target);
instanceCache.set(idx, unshared ? null : resolvedObject);