package com.thoughtworks.xstream.mapper; import com.thoughtworks.xstream.XStreamException; import com.thoughtworks.xstream.core.Caching; import com.thoughtworks.xstream.security.ForbiddenClassException; import com.ubtrobot.jimu.robotapi.PeripheralType; import java.util.Collections; import java.util.HashMap; import java.util.Map; /* loaded from: classes.dex */ public class CachingMapper extends MapperWrapper implements Caching { private transient Map realClassCache; public CachingMapper(Mapper mapper) { super(mapper); readResolve(); } private Object readResolve() { this.realClassCache = Collections.synchronizedMap(new HashMap(PeripheralType.SERVO)); return this; } @Override // com.thoughtworks.xstream.core.Caching public void flushCache() { this.realClassCache.clear(); } @Override // com.thoughtworks.xstream.mapper.MapperWrapper, com.thoughtworks.xstream.mapper.Mapper public Class realClass(String str) { Object obj = this.realClassCache.get(str); if (obj != null) { if (obj instanceof Class) { return (Class) obj; } throw ((XStreamException) obj); } try { Class realClass = super.realClass(str); this.realClassCache.put(str, realClass); return realClass; } catch (CannotResolveClassException e) { this.realClassCache.put(str, e); throw e; } catch (ForbiddenClassException e2) { this.realClassCache.put(str, e2); throw e2; } } }