Initial commit
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ConversionException;
|
||||
import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
|
||||
import com.thoughtworks.xstream.core.util.Fields;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AbstractAttributedCharacterIteratorAttributeConverter extends AbstractSingleValueConverter {
|
||||
static /* synthetic */ Class class$java$lang$String;
|
||||
static /* synthetic */ Class class$java$text$AttributedCharacterIterator$Attribute;
|
||||
static /* synthetic */ Class class$java$util$Map;
|
||||
private static final Method getName;
|
||||
private static final Map instanceMaps = new HashMap();
|
||||
private transient Map attributeMap;
|
||||
private final Class type;
|
||||
|
||||
static {
|
||||
Class cls;
|
||||
Method method = null;
|
||||
try {
|
||||
if (class$java$text$AttributedCharacterIterator$Attribute == null) {
|
||||
cls = class$("java.text.AttributedCharacterIterator$Attribute");
|
||||
class$java$text$AttributedCharacterIterator$Attribute = cls;
|
||||
} else {
|
||||
cls = class$java$text$AttributedCharacterIterator$Attribute;
|
||||
}
|
||||
method = cls.getDeclaredMethod("getName", null);
|
||||
if (!method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
} catch (NoSuchMethodException | SecurityException unused) {
|
||||
}
|
||||
getName = method;
|
||||
}
|
||||
|
||||
public AbstractAttributedCharacterIteratorAttributeConverter(Class cls) {
|
||||
Class cls2 = class$java$text$AttributedCharacterIterator$Attribute;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.text.AttributedCharacterIterator$Attribute");
|
||||
class$java$text$AttributedCharacterIterator$Attribute = cls2;
|
||||
}
|
||||
if (cls2.isAssignableFrom(cls)) {
|
||||
this.type = cls;
|
||||
readResolve();
|
||||
return;
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(cls.getName());
|
||||
stringBuffer.append(" is not a ");
|
||||
Class cls3 = class$java$text$AttributedCharacterIterator$Attribute;
|
||||
if (cls3 == null) {
|
||||
cls3 = class$("java.text.AttributedCharacterIterator$Attribute");
|
||||
class$java$text$AttributedCharacterIterator$Attribute = cls3;
|
||||
}
|
||||
stringBuffer.append(cls3.getName());
|
||||
throw new IllegalArgumentException(stringBuffer.toString());
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getName(AttributedCharacterIterator.Attribute attribute) {
|
||||
Method method = getName;
|
||||
Throwable th = null;
|
||||
if (method != null) {
|
||||
try {
|
||||
return (String) method.invoke(attribute, null);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
th = e;
|
||||
}
|
||||
}
|
||||
String attribute2 = attribute.toString();
|
||||
String name = attribute.getClass().getName();
|
||||
if (attribute2.startsWith(name)) {
|
||||
return attribute2.substring(name.length() + 1, attribute2.length() - 1);
|
||||
}
|
||||
ConversionException conversionException = new ConversionException("Cannot find name of attribute", th);
|
||||
conversionException.add("attribute-type", name);
|
||||
throw conversionException;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
boolean z;
|
||||
Class<?> cls;
|
||||
this.attributeMap = (Map) instanceMaps.get(this.type.getName());
|
||||
if (this.attributeMap == null) {
|
||||
this.attributeMap = new HashMap();
|
||||
Class cls2 = this.type;
|
||||
Class cls3 = class$java$util$Map;
|
||||
if (cls3 == null) {
|
||||
cls3 = class$("java.util.Map");
|
||||
class$java$util$Map = cls3;
|
||||
}
|
||||
Field locate = Fields.locate(cls2, cls3, true);
|
||||
if (locate != null) {
|
||||
try {
|
||||
Map map = (Map) Fields.read(locate, null);
|
||||
if (map != null) {
|
||||
Iterator it = map.entrySet().iterator();
|
||||
loop1: while (true) {
|
||||
while (z && it.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
Class<?> cls4 = entry.getKey().getClass();
|
||||
if (class$java$lang$String == null) {
|
||||
cls = class$("java.lang.String");
|
||||
class$java$lang$String = cls;
|
||||
} else {
|
||||
cls = class$java$lang$String;
|
||||
}
|
||||
z = cls4 == cls && entry.getValue().getClass() == this.type;
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
this.attributeMap.putAll(map);
|
||||
}
|
||||
}
|
||||
} catch (ObjectAccessException unused) {
|
||||
}
|
||||
}
|
||||
if (this.attributeMap.isEmpty()) {
|
||||
try {
|
||||
Field[] declaredFields = this.type.getDeclaredFields();
|
||||
for (int i = 0; i < declaredFields.length; i++) {
|
||||
if ((declaredFields[i].getType() == this.type) == Modifier.isStatic(declaredFields[i].getModifiers())) {
|
||||
AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.Attribute) Fields.read(declaredFields[i], null);
|
||||
this.attributeMap.put(toString(attribute), attribute);
|
||||
}
|
||||
}
|
||||
} catch (ObjectAccessException unused2) {
|
||||
this.attributeMap.clear();
|
||||
} catch (NoClassDefFoundError unused3) {
|
||||
this.attributeMap.clear();
|
||||
} catch (SecurityException unused4) {
|
||||
this.attributeMap.clear();
|
||||
}
|
||||
}
|
||||
instanceMaps.put(this.type.getName(), this.attributeMap);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter, com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return cls == this.type && !this.attributeMap.isEmpty();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter, com.thoughtworks.xstream.converters.SingleValueConverter
|
||||
public Object fromString(String str) {
|
||||
if (this.attributeMap.containsKey(str)) {
|
||||
return this.attributeMap.get(str);
|
||||
}
|
||||
ConversionException conversionException = new ConversionException("Cannot find attribute");
|
||||
conversionException.add("attribute-type", this.type.getName());
|
||||
conversionException.add("attribute-name", str);
|
||||
throw conversionException;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter, com.thoughtworks.xstream.converters.SingleValueConverter
|
||||
public String toString(Object obj) {
|
||||
return getName((AttributedCharacterIterator.Attribute) obj);
|
||||
}
|
||||
}
|
@@ -0,0 +1,383 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ConversionException;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.core.Caching;
|
||||
import com.thoughtworks.xstream.core.ReferencingMarshallingContext;
|
||||
import com.thoughtworks.xstream.core.util.Fields;
|
||||
import com.thoughtworks.xstream.core.util.SerializationMembers;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.mapper.Mapper;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractReflectionConverter implements Converter, Caching {
|
||||
static /* synthetic */ Class class$com$thoughtworks$xstream$mapper$Mapper$Null;
|
||||
static /* synthetic */ Class class$java$lang$Object;
|
||||
static /* synthetic */ Class class$java$util$Collection;
|
||||
static /* synthetic */ Class class$java$util$Map;
|
||||
static /* synthetic */ Class class$java$util$Map$Entry;
|
||||
protected final Mapper mapper;
|
||||
private transient ReflectionProvider pureJavaReflectionProvider;
|
||||
protected final ReflectionProvider reflectionProvider;
|
||||
protected transient SerializationMethodInvoker serializationMethodInvoker = new SerializationMethodInvoker();
|
||||
protected transient SerializationMembers serializationMembers = this.serializationMethodInvoker.serializationMembers;
|
||||
|
||||
private static class ArraysList extends ArrayList {
|
||||
final Class physicalFieldType;
|
||||
|
||||
ArraysList(Class cls) {
|
||||
this.physicalFieldType = cls;
|
||||
}
|
||||
|
||||
Object toPhysicalArray() {
|
||||
Object[] array = toArray();
|
||||
Object newInstance = Array.newInstance(this.physicalFieldType.getComponentType(), array.length);
|
||||
if (this.physicalFieldType.getComponentType().isPrimitive()) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
Array.set(newInstance, i, Array.get(array, i));
|
||||
}
|
||||
} else {
|
||||
System.arraycopy(array, 0, newInstance, 0, array.length);
|
||||
}
|
||||
return newInstance;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DuplicateFieldException extends ConversionException {
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public DuplicateFieldException(java.lang.String r3) {
|
||||
/*
|
||||
r2 = this;
|
||||
java.lang.StringBuffer r0 = new java.lang.StringBuffer
|
||||
r0.<init>()
|
||||
java.lang.String r1 = "Duplicate field "
|
||||
r0.append(r1)
|
||||
r0.append(r3)
|
||||
java.lang.String r0 = r0.toString()
|
||||
r2.<init>(r0)
|
||||
java.lang.String r0 = "field"
|
||||
r2.add(r0, r3)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.DuplicateFieldException.<init>(java.lang.String):void");
|
||||
}
|
||||
}
|
||||
|
||||
private static class FieldInfo extends FieldLocation {
|
||||
final Class type;
|
||||
final Object value;
|
||||
|
||||
FieldInfo(String str, Class cls, Class cls2, Object obj) {
|
||||
super(str, cls2);
|
||||
this.type = cls;
|
||||
this.value = obj;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FieldLocation {
|
||||
final Class definedIn;
|
||||
final String fieldName;
|
||||
|
||||
FieldLocation(String str, Class cls) {
|
||||
this.fieldName = str;
|
||||
this.definedIn = cls;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
FieldLocation fieldLocation = (FieldLocation) obj;
|
||||
if (this.definedIn != fieldLocation.definedIn) {
|
||||
return false;
|
||||
}
|
||||
String str = this.fieldName;
|
||||
if (str == null) {
|
||||
if (fieldLocation.fieldName != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!str.equals(fieldLocation.fieldName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
Class cls = this.definedIn;
|
||||
int hashCode = ((cls == null ? 0 : cls.getName().hashCode()) + 7) * 7;
|
||||
String str = this.fieldName;
|
||||
return hashCode + (str != null ? str.hashCode() : 0);
|
||||
}
|
||||
}
|
||||
|
||||
private interface FieldMarshaller {
|
||||
void writeField(String str, String str2, Class cls, Class cls2, Object obj);
|
||||
|
||||
void writeItem(Object obj);
|
||||
}
|
||||
|
||||
private class MappingList extends AbstractList {
|
||||
private final Map fieldCache = new HashMap();
|
||||
private final String keyFieldName;
|
||||
private final Map map;
|
||||
|
||||
public MappingList(Map map, String str) {
|
||||
this.map = map;
|
||||
this.keyFieldName = str;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public boolean add(Object obj) {
|
||||
if (obj == null) {
|
||||
boolean z = !this.map.containsKey(null);
|
||||
this.map.put(null, null);
|
||||
return z;
|
||||
}
|
||||
Class<?> cls = obj.getClass();
|
||||
if (this.keyFieldName != null) {
|
||||
Field field = (Field) this.fieldCache.get(cls);
|
||||
if (field == null) {
|
||||
field = AbstractReflectionConverter.this.reflectionProvider.getField(cls, this.keyFieldName);
|
||||
this.fieldCache.put(cls, field);
|
||||
}
|
||||
if (field != null) {
|
||||
return this.map.put(Fields.read(field, obj), obj) == null;
|
||||
}
|
||||
} else if (obj instanceof Map.Entry) {
|
||||
Map.Entry entry = (Map.Entry) obj;
|
||||
return this.map.put(entry.getKey(), entry.getValue()) == null;
|
||||
}
|
||||
ConversionException conversionException = new ConversionException("Element is not defined as entry for implicit map");
|
||||
conversionException.add("map-type", this.map.getClass().getName());
|
||||
conversionException.add("element-type", obj.getClass().getName());
|
||||
throw conversionException;
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractList, java.util.List
|
||||
public Object get(int i) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
||||
public int size() {
|
||||
return this.map.size();
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnknownFieldException extends ConversionException {
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public UnknownFieldException(java.lang.String r3, java.lang.String r4) {
|
||||
/*
|
||||
r2 = this;
|
||||
java.lang.StringBuffer r0 = new java.lang.StringBuffer
|
||||
r0.<init>()
|
||||
java.lang.String r1 = "No such field "
|
||||
r0.append(r1)
|
||||
r0.append(r3)
|
||||
java.lang.String r3 = "."
|
||||
r0.append(r3)
|
||||
r0.append(r4)
|
||||
java.lang.String r3 = r0.toString()
|
||||
r2.<init>(r3)
|
||||
java.lang.String r3 = "field"
|
||||
r2.add(r3, r4)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.UnknownFieldException.<init>(java.lang.String, java.lang.String):void");
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractReflectionConverter(Mapper mapper, ReflectionProvider reflectionProvider) {
|
||||
this.mapper = mapper;
|
||||
this.reflectionProvider = reflectionProvider;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUnknownField(Class cls, String str, Class cls2, String str2) {
|
||||
if (cls == null) {
|
||||
for (Class cls3 = cls2; cls3 != null; cls3 = cls3.getSuperclass()) {
|
||||
if (!this.mapper.shouldSerializeMember(cls3, str2)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new UnknownFieldException(cls2.getName(), str);
|
||||
}
|
||||
|
||||
private Class readDeclaringClass(HierarchicalStreamReader hierarchicalStreamReader) {
|
||||
String aliasForSystemAttribute = this.mapper.aliasForSystemAttribute("defined-in");
|
||||
String attribute = aliasForSystemAttribute == null ? null : hierarchicalStreamReader.getAttribute(aliasForSystemAttribute);
|
||||
if (attribute == null) {
|
||||
return null;
|
||||
}
|
||||
return this.mapper.realClass(attribute);
|
||||
}
|
||||
|
||||
private void writeValueToImplicitCollection(Object obj, Map map, Object obj2, FieldLocation fieldLocation) {
|
||||
Collection collection = (Collection) map.get(fieldLocation);
|
||||
if (collection == null) {
|
||||
Field fieldOrNull = this.reflectionProvider.getFieldOrNull(fieldLocation.definedIn, fieldLocation.fieldName);
|
||||
Class type = fieldOrNull != null ? fieldOrNull.getType() : this.reflectionProvider.getFieldType(obj2, fieldLocation.fieldName, null);
|
||||
if (type.isArray()) {
|
||||
collection = new ArraysList(type);
|
||||
} else {
|
||||
Class<?> defaultImplementationOf = this.mapper.defaultImplementationOf(type);
|
||||
Class cls = class$java$util$Collection;
|
||||
if (cls == null) {
|
||||
cls = class$("java.util.Collection");
|
||||
class$java$util$Collection = cls;
|
||||
}
|
||||
if (!cls.isAssignableFrom(defaultImplementationOf)) {
|
||||
Class cls2 = class$java$util$Map;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.util.Map");
|
||||
class$java$util$Map = cls2;
|
||||
}
|
||||
if (!cls2.isAssignableFrom(defaultImplementationOf)) {
|
||||
ObjectAccessException objectAccessException = new ObjectAccessException("Field is configured for an implicit Collection or Map, but is of an incompatible type");
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(obj2.getClass().getName());
|
||||
stringBuffer.append(".");
|
||||
stringBuffer.append(fieldLocation.fieldName);
|
||||
objectAccessException.add("field", stringBuffer.toString());
|
||||
objectAccessException.add("field-type", defaultImplementationOf.getName());
|
||||
throw objectAccessException;
|
||||
}
|
||||
}
|
||||
if (this.pureJavaReflectionProvider == null) {
|
||||
this.pureJavaReflectionProvider = new PureJavaReflectionProvider();
|
||||
}
|
||||
Object newInstance = this.pureJavaReflectionProvider.newInstance(defaultImplementationOf);
|
||||
Collection mappingList = newInstance instanceof Collection ? (Collection) newInstance : new MappingList((Map) newInstance, this.mapper.getImplicitCollectionDefForFieldName(fieldLocation.definedIn, fieldLocation.fieldName).getKeyFieldName());
|
||||
this.reflectionProvider.writeField(obj2, fieldLocation.fieldName, newInstance, fieldOrNull != null ? fieldOrNull.getDeclaringClass() : null);
|
||||
collection = mappingList;
|
||||
}
|
||||
map.put(fieldLocation, collection);
|
||||
}
|
||||
collection.add(obj);
|
||||
}
|
||||
|
||||
protected boolean canAccess(Class cls) {
|
||||
try {
|
||||
this.reflectionProvider.getFieldOrNull(cls, "%");
|
||||
return true;
|
||||
} catch (NoClassDefFoundError unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:19:0x017f A[SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:23:0x008d A[SYNTHETIC] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
protected void doMarshal(final java.lang.Object r20, final com.thoughtworks.xstream.io.HierarchicalStreamWriter r21, final com.thoughtworks.xstream.converters.MarshallingContext r22) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 399
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(java.lang.Object, com.thoughtworks.xstream.io.HierarchicalStreamWriter, com.thoughtworks.xstream.converters.MarshallingContext):void");
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:51:0x0100 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:59:0x0218 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:62:0x022e */
|
||||
/* JADX WARN: Removed duplicated region for block: B:76:0x0103 */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public java.lang.Object doUnmarshal(java.lang.Object r13, com.thoughtworks.xstream.io.HierarchicalStreamReader r14, com.thoughtworks.xstream.converters.UnmarshallingContext r15) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 676
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(java.lang.Object, com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters.UnmarshallingContext):java.lang.Object");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.Caching
|
||||
public void flushCache() {
|
||||
this.serializationMethodInvoker.flushCache();
|
||||
}
|
||||
|
||||
protected Object instantiateNewInstance(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
String aliasForSystemAttribute = this.mapper.aliasForSystemAttribute("resolves-to");
|
||||
String attribute = aliasForSystemAttribute == null ? null : hierarchicalStreamReader.getAttribute(aliasForSystemAttribute);
|
||||
Object currentObject = unmarshallingContext.currentObject();
|
||||
return currentObject != null ? currentObject : attribute != null ? this.reflectionProvider.newInstance(this.mapper.realClass(attribute)) : this.reflectionProvider.newInstance(unmarshallingContext.getRequiredType());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
Object callWriteReplace = this.serializationMembers.callWriteReplace(obj);
|
||||
if (callWriteReplace != obj && (marshallingContext instanceof ReferencingMarshallingContext)) {
|
||||
((ReferencingMarshallingContext) marshallingContext).replace(obj, callWriteReplace);
|
||||
}
|
||||
if (callWriteReplace.getClass() == obj.getClass()) {
|
||||
doMarshal(callWriteReplace, hierarchicalStreamWriter, marshallingContext);
|
||||
return;
|
||||
}
|
||||
String aliasForSystemAttribute = this.mapper.aliasForSystemAttribute("resolves-to");
|
||||
if (aliasForSystemAttribute != null) {
|
||||
hierarchicalStreamWriter.addAttribute(aliasForSystemAttribute, this.mapper.serializedClass(callWriteReplace.getClass()));
|
||||
}
|
||||
marshallingContext.convertAnother(callWriteReplace);
|
||||
}
|
||||
|
||||
protected void marshallField(MarshallingContext marshallingContext, Object obj, Field field) {
|
||||
marshallingContext.convertAnother(obj, this.mapper.getLocalConverter(field.getDeclaringClass(), field.getName()));
|
||||
}
|
||||
|
||||
protected Object readResolve() {
|
||||
this.serializationMethodInvoker = new SerializationMethodInvoker();
|
||||
this.serializationMembers = this.serializationMethodInvoker.serializationMembers;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected boolean shouldUnmarshalField(Field field) {
|
||||
return !Modifier.isTransient(field.getModifiers()) || shouldUnmarshalTransientFields();
|
||||
}
|
||||
|
||||
protected boolean shouldUnmarshalTransientFields() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
return this.serializationMembers.callReadResolve(doUnmarshal(instantiateNewInstance(hierarchicalStreamReader, unmarshallingContext), hierarchicalStreamReader, unmarshallingContext));
|
||||
}
|
||||
|
||||
protected Object unmarshallField(UnmarshallingContext unmarshallingContext, Object obj, Class cls, Field field) {
|
||||
return unmarshallingContext.convertAnother(obj, cls, this.mapper.getLocalConverter(field.getDeclaringClass(), field.getName()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,564 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.ijm.dataencryption.de.DataDecryptTool;
|
||||
import com.thoughtworks.xstream.converters.ConversionException;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.reflection.ReflectionProvider;
|
||||
import com.thoughtworks.xstream.core.ClassLoaderReference;
|
||||
import com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.mapper.Mapper;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.sf.cglib.proxy.Callback;
|
||||
import net.sf.cglib.proxy.CallbackFilter;
|
||||
import net.sf.cglib.proxy.Enhancer;
|
||||
import net.sf.cglib.proxy.Factory;
|
||||
import net.sf.cglib.proxy.NoOp;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CGLIBEnhancedConverter extends SerializableConverter {
|
||||
private static String CALLBACK_MARKER = "CGLIB$CALLBACK_";
|
||||
private static String DEFAULT_NAMING_MARKER = "$$EnhancerByCGLIB$$";
|
||||
static /* synthetic */ Class class$com$thoughtworks$xstream$converters$reflection$CGLIBEnhancedConverter;
|
||||
static /* synthetic */ Class class$com$thoughtworks$xstream$mapper$CGLIBMapper$Marker;
|
||||
static /* synthetic */ Class class$java$lang$Class;
|
||||
static /* synthetic */ Class class$java$lang$String;
|
||||
static /* synthetic */ Class class$java$util$HashMap;
|
||||
static /* synthetic */ Class class$net$sf$cglib$proxy$Callback;
|
||||
static /* synthetic */ Class class$net$sf$cglib$proxy$Factory;
|
||||
static /* synthetic */ Class class$net$sf$cglib$proxy$MethodInterceptor;
|
||||
static /* synthetic */ Class class$net$sf$cglib$proxy$NoOp;
|
||||
private transient Map fieldCache;
|
||||
|
||||
private static class CGLIBFilteringReflectionProvider extends ReflectionProviderWrapper {
|
||||
public CGLIBFilteringReflectionProvider(ReflectionProvider reflectionProvider) {
|
||||
super(reflectionProvider);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProviderWrapper, com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public void visitSerializableFields(Object obj, final ReflectionProvider.Visitor visitor) {
|
||||
this.wrapped.visitSerializableFields(obj, new ReflectionProvider.Visitor() { // from class: com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter.CGLIBFilteringReflectionProvider.1
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider.Visitor
|
||||
public void visit(String str, Class cls, Class cls2, Object obj2) {
|
||||
if (str.startsWith("CGLIB$")) {
|
||||
return;
|
||||
}
|
||||
visitor.visit(str, cls, cls2, obj2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static class ReverseEngineeredCallbackFilter implements CallbackFilter {
|
||||
private final Map callbackIndexMap;
|
||||
|
||||
public ReverseEngineeredCallbackFilter(Map map) {
|
||||
this.callbackIndexMap = map;
|
||||
}
|
||||
|
||||
public int accept(Method method) {
|
||||
if (this.callbackIndexMap.containsKey(method)) {
|
||||
return ((Integer) this.callbackIndexMap.get(method)).intValue();
|
||||
}
|
||||
ConversionException conversionException = new ConversionException("CGLIB callback not detected in reverse engineering");
|
||||
conversionException.add("CGLIB-callback", method.toString());
|
||||
throw conversionException;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ReverseEngineeringInvocationHandler implements InvocationHandler {
|
||||
private final Integer index;
|
||||
private final Map indexMap;
|
||||
|
||||
public ReverseEngineeringInvocationHandler(int i, Map map) {
|
||||
this.indexMap = map;
|
||||
this.index = new Integer(i);
|
||||
}
|
||||
|
||||
@Override // java.lang.reflect.InvocationHandler
|
||||
public Object invoke(Object obj, Method method, Object[] objArr) throws Throwable {
|
||||
Map map = this.indexMap;
|
||||
map.put(map.get(null), this.index);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public CGLIBEnhancedConverter(Mapper mapper, ReflectionProvider reflectionProvider, ClassLoaderReference classLoaderReference) {
|
||||
super(mapper, new CGLIBFilteringReflectionProvider(reflectionProvider), classLoaderReference);
|
||||
this.fieldCache = new HashMap();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Object create(Enhancer enhancer, List list, boolean z) {
|
||||
Object create = enhancer.create();
|
||||
if (z) {
|
||||
((Factory) create).setCallbacks((Callback[]) list.toArray(new Callback[list.size()]));
|
||||
}
|
||||
return create;
|
||||
}
|
||||
|
||||
private Map createCallbackIndexMap(Factory factory) {
|
||||
Class cls;
|
||||
Method method;
|
||||
Callback[] callbacks = factory.getCallbacks();
|
||||
Callback[] callbackArr = new Callback[callbacks.length];
|
||||
Map hashMap = new HashMap();
|
||||
int i = -1;
|
||||
for (int i2 = 0; i2 < callbacks.length; i2++) {
|
||||
Callback callback = callbacks[i2];
|
||||
if (callback == null) {
|
||||
callbackArr[i2] = null;
|
||||
} else {
|
||||
Class cls2 = class$net$sf$cglib$proxy$NoOp;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("net.sf.cglib.proxy.NoOp");
|
||||
class$net$sf$cglib$proxy$NoOp = cls2;
|
||||
}
|
||||
if (cls2.isAssignableFrom(callback.getClass())) {
|
||||
callbackArr[i2] = NoOp.INSTANCE;
|
||||
i = i2;
|
||||
} else {
|
||||
callbackArr[i2] = createReverseEngineeredCallbackOfProperType(callback, i2, hashMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
factory.setCallbacks(callbackArr);
|
||||
HashSet<Class<?>> hashSet = new HashSet();
|
||||
HashSet hashSet2 = new HashSet();
|
||||
r6 = factory.getClass();
|
||||
do {
|
||||
hashSet2.addAll(Arrays.asList(r6.getDeclaredMethods()));
|
||||
hashSet2.addAll(Arrays.asList(r6.getMethods()));
|
||||
hashSet.addAll(Arrays.asList(r6.getInterfaces()));
|
||||
r6 = r6.getSuperclass();
|
||||
} while (r6 != null);
|
||||
for (Class<?> cls3 : hashSet) {
|
||||
hashSet2.addAll(Arrays.asList(cls3.getDeclaredMethods()));
|
||||
}
|
||||
Iterator it = hashSet2.iterator();
|
||||
while (it.hasNext()) {
|
||||
Method method2 = (Method) it.next();
|
||||
if (!method2.isAccessible()) {
|
||||
method2.setAccessible(true);
|
||||
}
|
||||
if (class$net$sf$cglib$proxy$Factory == null) {
|
||||
cls = class$("net.sf.cglib.proxy.Factory");
|
||||
class$net$sf$cglib$proxy$Factory = cls;
|
||||
} else {
|
||||
cls = class$net$sf$cglib$proxy$Factory;
|
||||
}
|
||||
if (!cls.isAssignableFrom(method2.getDeclaringClass()) && (method2.getModifiers() & 24) <= 0) {
|
||||
Class[] parameterTypes = method2.getParameterTypes();
|
||||
try {
|
||||
try {
|
||||
method = (method2.getModifiers() & DataDecryptTool.DECRYPT_SP_FILE) > 0 ? factory.getClass().getMethod(method2.getName(), method2.getParameterTypes()) : method2;
|
||||
} catch (NoSuchMethodException unused) {
|
||||
ConversionException conversionException = new ConversionException("CGLIB enhanced proxies wit abstract nethod that has not been implemented");
|
||||
conversionException.add("proxy-superclass", cls3.getSuperclass().getName());
|
||||
conversionException.add("method", method2.toString());
|
||||
throw conversionException;
|
||||
} catch (InvocationTargetException unused2) {
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e = e;
|
||||
}
|
||||
try {
|
||||
hashMap.put(null, method2);
|
||||
method.invoke(factory, parameterTypes == null ? null : createNullArguments(parameterTypes));
|
||||
if (hashMap.containsKey(method2)) {
|
||||
it.remove();
|
||||
}
|
||||
} catch (IllegalAccessException e2) {
|
||||
e = e2;
|
||||
method2 = method;
|
||||
ObjectAccessException objectAccessException = new ObjectAccessException("Cannot access method", e);
|
||||
objectAccessException.add("method", method2.toString());
|
||||
throw objectAccessException;
|
||||
}
|
||||
}
|
||||
it.remove();
|
||||
}
|
||||
if (i >= 0) {
|
||||
Integer num = new Integer(i);
|
||||
Iterator it2 = hashSet2.iterator();
|
||||
while (it2.hasNext()) {
|
||||
hashMap.put(it2.next(), num);
|
||||
}
|
||||
}
|
||||
factory.setCallbacks(callbacks);
|
||||
hashMap.remove(null);
|
||||
return hashMap;
|
||||
} catch (Throwable th) {
|
||||
factory.setCallbacks(callbacks);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
private Object[] createNullArguments(Class[] clsArr) {
|
||||
Object[] objArr = new Object[clsArr.length];
|
||||
for (int i = 0; i < objArr.length; i++) {
|
||||
Class cls = clsArr[i];
|
||||
if (cls.isPrimitive()) {
|
||||
if (cls == Byte.TYPE) {
|
||||
objArr[i] = new Byte((byte) 0);
|
||||
} else if (cls == Short.TYPE) {
|
||||
objArr[i] = new Short((short) 0);
|
||||
} else if (cls == Integer.TYPE) {
|
||||
objArr[i] = new Integer(0);
|
||||
} else if (cls == Long.TYPE) {
|
||||
objArr[i] = new Long(0L);
|
||||
} else if (cls == Float.TYPE) {
|
||||
objArr[i] = new Float(0.0f);
|
||||
} else if (cls == Double.TYPE) {
|
||||
objArr[i] = new Double(0.0d);
|
||||
} else if (cls == Character.TYPE) {
|
||||
objArr[i] = new Character((char) 0);
|
||||
} else {
|
||||
objArr[i] = Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return objArr;
|
||||
}
|
||||
|
||||
private Callback createReverseEngineeredCallbackOfProperType(Callback callback, int i, Map map) {
|
||||
Class<?> cls = null;
|
||||
Class<?>[] interfaces = callback.getClass().getInterfaces();
|
||||
int i2 = 0;
|
||||
while (i2 < interfaces.length) {
|
||||
Class cls2 = class$net$sf$cglib$proxy$Callback;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("net.sf.cglib.proxy.Callback");
|
||||
class$net$sf$cglib$proxy$Callback = cls2;
|
||||
}
|
||||
if (cls2.isAssignableFrom(interfaces[i2])) {
|
||||
cls = interfaces[i2];
|
||||
Class<?> cls3 = class$net$sf$cglib$proxy$Callback;
|
||||
if (cls3 == null) {
|
||||
cls3 = class$("net.sf.cglib.proxy.Callback");
|
||||
class$net$sf$cglib$proxy$Callback = cls3;
|
||||
}
|
||||
if (cls == cls3) {
|
||||
ConversionException conversionException = new ConversionException("Cannot handle CGLIB callback");
|
||||
conversionException.add("CGLIB-callback-type", callback.getClass().getName());
|
||||
throw conversionException;
|
||||
}
|
||||
Class<?>[] interfaces2 = cls.getInterfaces();
|
||||
List asList = Arrays.asList(interfaces2);
|
||||
Class cls4 = class$net$sf$cglib$proxy$Callback;
|
||||
if (cls4 == null) {
|
||||
cls4 = class$("net.sf.cglib.proxy.Callback");
|
||||
class$net$sf$cglib$proxy$Callback = cls4;
|
||||
}
|
||||
if (asList.contains(cls4)) {
|
||||
break;
|
||||
}
|
||||
interfaces = interfaces2;
|
||||
i2 = -1;
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
return (Callback) Proxy.newProxyInstance(cls.getClassLoader(), new Class[]{cls}, new ReverseEngineeringInvocationHandler(i, map));
|
||||
}
|
||||
|
||||
private Callback[] getCallbacks(Object obj) {
|
||||
Class<?> cls = obj.getClass();
|
||||
List list = (List) this.fieldCache.get(cls.getName());
|
||||
if (list == null) {
|
||||
list = new ArrayList();
|
||||
this.fieldCache.put(cls.getName(), list);
|
||||
int i = 0;
|
||||
while (true) {
|
||||
try {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(CALLBACK_MARKER);
|
||||
stringBuffer.append(i);
|
||||
Field declaredField = cls.getDeclaredField(stringBuffer.toString());
|
||||
if (!declaredField.isAccessible()) {
|
||||
declaredField.setAccessible(true);
|
||||
}
|
||||
list.add(declaredField);
|
||||
i++;
|
||||
} catch (NoSuchFieldException unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (int i2 = 0; i2 < list.size(); i2++) {
|
||||
try {
|
||||
arrayList.add(((Field) list.get(i2)).get(obj));
|
||||
} catch (IllegalAccessException e) {
|
||||
ObjectAccessException objectAccessException = new ObjectAccessException("Cannot access field", e);
|
||||
StringBuffer stringBuffer2 = new StringBuffer();
|
||||
stringBuffer2.append(cls.getName());
|
||||
stringBuffer2.append(".");
|
||||
stringBuffer2.append(CALLBACK_MARKER);
|
||||
stringBuffer2.append(i2);
|
||||
objectAccessException.add("field", stringBuffer2.toString());
|
||||
throw objectAccessException;
|
||||
}
|
||||
}
|
||||
return (Callback[]) arrayList.toArray(new Callback[arrayList.size()]);
|
||||
}
|
||||
|
||||
private void readCallback(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, List list, List list2) {
|
||||
Callback callback = (Callback) unmarshallingContext.convertAnother(null, this.mapper.realClass(hierarchicalStreamReader.getNodeName()));
|
||||
list2.add(callback);
|
||||
if (callback == null) {
|
||||
list.add(NoOp.INSTANCE);
|
||||
} else {
|
||||
list.add(callback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.SerializableConverter, com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
if (cls == null || !Enhancer.isEnhanced(cls) || cls.getName().indexOf(DEFAULT_NAMING_MARKER) <= 0) {
|
||||
Class cls2 = class$com$thoughtworks$xstream$mapper$CGLIBMapper$Marker;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("com.thoughtworks.xstream.mapper.CGLIBMapper$Marker");
|
||||
class$com$thoughtworks$xstream$mapper$CGLIBMapper$Marker = cls2;
|
||||
}
|
||||
if (cls != cls2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.SerializableConverter
|
||||
protected List hierarchyFor(Class cls) {
|
||||
List hierarchyFor = super.hierarchyFor(cls);
|
||||
hierarchyFor.remove(hierarchyFor.size() - 1);
|
||||
return hierarchyFor;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter, com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
Class cls;
|
||||
Class<?> cls2 = obj.getClass();
|
||||
Class cls3 = class$net$sf$cglib$proxy$Factory;
|
||||
if (cls3 == null) {
|
||||
cls3 = class$("net.sf.cglib.proxy.Factory");
|
||||
class$net$sf$cglib$proxy$Factory = cls3;
|
||||
}
|
||||
boolean isAssignableFrom = cls3.isAssignableFrom(cls2);
|
||||
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, "type", cls2);
|
||||
marshallingContext.convertAnother(cls2.getSuperclass());
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("interfaces");
|
||||
Class<?>[] interfaces = cls2.getInterfaces();
|
||||
for (int i = 0; i < interfaces.length; i++) {
|
||||
Class<?> cls4 = interfaces[i];
|
||||
Class<?> cls5 = class$net$sf$cglib$proxy$Factory;
|
||||
if (cls5 == null) {
|
||||
cls5 = class$("net.sf.cglib.proxy.Factory");
|
||||
class$net$sf$cglib$proxy$Factory = cls5;
|
||||
}
|
||||
if (cls4 != cls5) {
|
||||
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, this.mapper.serializedClass(interfaces[i].getClass()), interfaces[i].getClass());
|
||||
marshallingContext.convertAnother(interfaces[i]);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("hasFactory");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(isAssignableFrom));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
Callback[] callbacks = isAssignableFrom ? ((Factory) obj).getCallbacks() : getCallbacks(obj);
|
||||
if (callbacks.length > 1) {
|
||||
if (!isAssignableFrom) {
|
||||
ConversionException conversionException = new ConversionException("Cannot handle CGLIB enhanced proxies without factory that have multiple callbacks");
|
||||
conversionException.add("proxy-superclass", cls2.getSuperclass().getName());
|
||||
conversionException.add("number-of-callbacks", String.valueOf(callbacks.length));
|
||||
throw conversionException;
|
||||
}
|
||||
Map createCallbackIndexMap = createCallbackIndexMap((Factory) obj);
|
||||
hierarchicalStreamWriter.startNode("callbacks");
|
||||
hierarchicalStreamWriter.startNode("mapping");
|
||||
marshallingContext.convertAnother(createCallbackIndexMap);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
boolean z = false;
|
||||
for (Callback callback : callbacks) {
|
||||
if (callback == null) {
|
||||
hierarchicalStreamWriter.startNode(this.mapper.serializedClass(null));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
} else {
|
||||
if (!z) {
|
||||
Class cls6 = class$net$sf$cglib$proxy$MethodInterceptor;
|
||||
if (cls6 == null) {
|
||||
cls6 = class$("net.sf.cglib.proxy.MethodInterceptor");
|
||||
class$net$sf$cglib$proxy$MethodInterceptor = cls6;
|
||||
}
|
||||
if (!cls6.isAssignableFrom(callback.getClass())) {
|
||||
z = false;
|
||||
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, this.mapper.serializedClass(callback.getClass()), callback.getClass());
|
||||
marshallingContext.convertAnother(callback);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
z = true;
|
||||
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, this.mapper.serializedClass(callback.getClass()), callback.getClass());
|
||||
marshallingContext.convertAnother(callback);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
if (callbacks.length > 1) {
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
try {
|
||||
Field declaredField = cls2.getDeclaredField("serialVersionUID");
|
||||
if (!declaredField.isAccessible()) {
|
||||
declaredField.setAccessible(true);
|
||||
}
|
||||
long j = declaredField.getLong(null);
|
||||
if (class$java$lang$String == null) {
|
||||
cls = class$("java.lang.String");
|
||||
class$java$lang$String = cls;
|
||||
} else {
|
||||
cls = class$java$lang$String;
|
||||
}
|
||||
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, "serialVersionUID", cls);
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(j));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
} catch (IllegalAccessException e) {
|
||||
ObjectAccessException objectAccessException = new ObjectAccessException("Cannot access field", e);
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(cls2.getName());
|
||||
stringBuffer.append(".serialVersionUID");
|
||||
objectAccessException.add("field", stringBuffer.toString());
|
||||
throw objectAccessException;
|
||||
} catch (NoSuchFieldException unused) {
|
||||
}
|
||||
if (z) {
|
||||
hierarchicalStreamWriter.startNode("instance");
|
||||
super.doMarshalConditionally(obj, hierarchicalStreamWriter, marshallingContext);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter
|
||||
protected Object readResolve() {
|
||||
super.readResolve();
|
||||
this.fieldCache = new HashMap();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter, com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
Map map;
|
||||
Enhancer enhancer = new Enhancer();
|
||||
hierarchicalStreamReader.moveDown();
|
||||
Class cls = class$java$lang$Class;
|
||||
if (cls == null) {
|
||||
cls = class$("java.lang.Class");
|
||||
class$java$lang$Class = cls;
|
||||
}
|
||||
Object obj = null;
|
||||
enhancer.setSuperclass((Class) unmarshallingContext.convertAnother(null, cls));
|
||||
hierarchicalStreamReader.moveUp();
|
||||
hierarchicalStreamReader.moveDown();
|
||||
ArrayList arrayList = new ArrayList();
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
arrayList.add(unmarshallingContext.convertAnother(null, this.mapper.realClass(hierarchicalStreamReader.getNodeName())));
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
enhancer.setInterfaces((Class[]) arrayList.toArray(new Class[arrayList.size()]));
|
||||
hierarchicalStreamReader.moveUp();
|
||||
hierarchicalStreamReader.moveDown();
|
||||
boolean booleanValue = Boolean.valueOf(hierarchicalStreamReader.getValue()).booleanValue();
|
||||
enhancer.setUseFactory(booleanValue);
|
||||
hierarchicalStreamReader.moveUp();
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
ArrayList arrayList3 = new ArrayList();
|
||||
hierarchicalStreamReader.moveDown();
|
||||
if ("callbacks".equals(hierarchicalStreamReader.getNodeName())) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
Class cls2 = class$java$util$HashMap;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.util.HashMap");
|
||||
class$java$util$HashMap = cls2;
|
||||
}
|
||||
map = (Map) unmarshallingContext.convertAnother(null, cls2);
|
||||
hierarchicalStreamReader.moveUp();
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
readCallback(hierarchicalStreamReader, unmarshallingContext, arrayList2, arrayList3);
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
} else {
|
||||
readCallback(hierarchicalStreamReader, unmarshallingContext, arrayList2, arrayList3);
|
||||
map = null;
|
||||
}
|
||||
enhancer.setCallbacks((Callback[]) arrayList2.toArray(new Callback[arrayList2.size()]));
|
||||
if (map != null) {
|
||||
enhancer.setCallbackFilter(new ReverseEngineeredCallbackFilter(map));
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
if (hierarchicalStreamReader.getNodeName().equals("serialVersionUID")) {
|
||||
enhancer.setSerialVersionUID(Long.valueOf(hierarchicalStreamReader.getValue()));
|
||||
} else if (hierarchicalStreamReader.getNodeName().equals("instance")) {
|
||||
obj = create(enhancer, arrayList3, booleanValue);
|
||||
super.doUnmarshalConditionally(obj, hierarchicalStreamReader, unmarshallingContext);
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
if (obj == null) {
|
||||
obj = create(enhancer, arrayList3, booleanValue);
|
||||
}
|
||||
return this.serializationMembers.callReadResolve(obj);
|
||||
}
|
||||
|
||||
public CGLIBEnhancedConverter(Mapper mapper, ReflectionProvider reflectionProvider, ClassLoader classLoader) {
|
||||
super(mapper, new CGLIBFilteringReflectionProvider(reflectionProvider), classLoader);
|
||||
this.fieldCache = new HashMap();
|
||||
}
|
||||
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public CGLIBEnhancedConverter(com.thoughtworks.xstream.mapper.Mapper r2, com.thoughtworks.xstream.converters.reflection.ReflectionProvider r3) {
|
||||
/*
|
||||
r1 = this;
|
||||
com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter$CGLIBFilteringReflectionProvider r0 = new com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter$CGLIBFilteringReflectionProvider
|
||||
r0.<init>(r3)
|
||||
java.lang.Class r3 = com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter.class$com$thoughtworks$xstream$converters$reflection$CGLIBEnhancedConverter
|
||||
if (r3 != 0) goto L11
|
||||
java.lang.String r3 = "com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter"
|
||||
java.lang.Class r3 = class$(r3)
|
||||
com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter.class$com$thoughtworks$xstream$converters$reflection$CGLIBEnhancedConverter = r3
|
||||
L11:
|
||||
java.lang.ClassLoader r3 = r3.getClassLoader()
|
||||
r1.<init>(r2, r0, r3)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter.<init>(com.thoughtworks.xstream.mapper.Mapper, com.thoughtworks.xstream.converters.reflection.ReflectionProvider):void");
|
||||
}
|
||||
}
|
@@ -0,0 +1,211 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ConversionException;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.core.ClassLoaderReference;
|
||||
import com.thoughtworks.xstream.core.JVM;
|
||||
import com.thoughtworks.xstream.core.ReferencingMarshallingContext;
|
||||
import com.thoughtworks.xstream.core.util.CustomObjectInputStream;
|
||||
import com.thoughtworks.xstream.core.util.CustomObjectOutputStream;
|
||||
import com.thoughtworks.xstream.core.util.HierarchicalStreams;
|
||||
import com.thoughtworks.xstream.core.util.SerializationMembers;
|
||||
import com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.mapper.Mapper;
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.NotActiveException;
|
||||
import java.io.ObjectInputValidation;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ExternalizableConverter implements Converter {
|
||||
static /* synthetic */ Class class$com$thoughtworks$xstream$converters$reflection$ExternalizableConverter;
|
||||
static /* synthetic */ Class class$java$io$Externalizable;
|
||||
private final ClassLoaderReference classLoaderReference;
|
||||
private Mapper mapper;
|
||||
private transient SerializationMembers serializationMembers;
|
||||
|
||||
public ExternalizableConverter(Mapper mapper, ClassLoaderReference classLoaderReference) {
|
||||
this.mapper = mapper;
|
||||
this.classLoaderReference = classLoaderReference;
|
||||
this.serializationMembers = new SerializationMembers();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
this.serializationMembers = new SerializationMembers();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
if (cls != null && JVM.canCreateDerivedObjectOutputStream()) {
|
||||
Class cls2 = class$java$io$Externalizable;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.io.Externalizable");
|
||||
class$java$io$Externalizable = cls2;
|
||||
}
|
||||
if (cls2.isAssignableFrom(cls)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, final HierarchicalStreamWriter hierarchicalStreamWriter, final MarshallingContext marshallingContext) {
|
||||
Object callWriteReplace = this.serializationMembers.callWriteReplace(obj);
|
||||
if (callWriteReplace != obj && (marshallingContext instanceof ReferencingMarshallingContext)) {
|
||||
((ReferencingMarshallingContext) marshallingContext).replace(obj, callWriteReplace);
|
||||
}
|
||||
if (callWriteReplace.getClass() != obj.getClass()) {
|
||||
String aliasForSystemAttribute = this.mapper.aliasForSystemAttribute("resolves-to");
|
||||
if (aliasForSystemAttribute != null) {
|
||||
hierarchicalStreamWriter.addAttribute(aliasForSystemAttribute, this.mapper.serializedClass(callWriteReplace.getClass()));
|
||||
}
|
||||
marshallingContext.convertAnother(callWriteReplace);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
CustomObjectOutputStream customObjectOutputStream = CustomObjectOutputStream.getInstance(marshallingContext, new CustomObjectOutputStream.StreamCallback() { // from class: com.thoughtworks.xstream.converters.reflection.ExternalizableConverter.1
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectOutputStream.StreamCallback
|
||||
public void close() {
|
||||
throw new UnsupportedOperationException("Objects are not allowed to call ObjectOutput.close() from writeExternal()");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectOutputStream.StreamCallback
|
||||
public void defaultWriteObject() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectOutputStream.StreamCallback
|
||||
public void flush() {
|
||||
hierarchicalStreamWriter.flush();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectOutputStream.StreamCallback
|
||||
public void writeFieldsToStream(Map map) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectOutputStream.StreamCallback
|
||||
public void writeToStream(Object obj2) {
|
||||
if (obj2 == null) {
|
||||
hierarchicalStreamWriter.startNode("null");
|
||||
hierarchicalStreamWriter.endNode();
|
||||
} else {
|
||||
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, ExternalizableConverter.this.mapper.serializedClass(obj2.getClass()), obj2.getClass());
|
||||
marshallingContext.convertAnother(obj2);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
});
|
||||
((Externalizable) callWriteReplace).writeExternal(customObjectOutputStream);
|
||||
customObjectOutputStream.popCallback();
|
||||
} catch (IOException e) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Cannot serialize ");
|
||||
stringBuffer.append(callWriteReplace.getClass().getName());
|
||||
stringBuffer.append(" using Externalization");
|
||||
throw new StreamException(stringBuffer.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(final HierarchicalStreamReader hierarchicalStreamReader, final UnmarshallingContext unmarshallingContext) {
|
||||
Class requiredType = unmarshallingContext.getRequiredType();
|
||||
try {
|
||||
Constructor declaredConstructor = requiredType.getDeclaredConstructor(null);
|
||||
if (!declaredConstructor.isAccessible()) {
|
||||
declaredConstructor.setAccessible(true);
|
||||
}
|
||||
final Externalizable externalizable = (Externalizable) declaredConstructor.newInstance(null);
|
||||
CustomObjectInputStream customObjectInputStream = CustomObjectInputStream.getInstance(unmarshallingContext, new CustomObjectInputStream.StreamCallback() { // from class: com.thoughtworks.xstream.converters.reflection.ExternalizableConverter.2
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectInputStream.StreamCallback
|
||||
public void close() {
|
||||
throw new UnsupportedOperationException("Objects are not allowed to call ObjectInput.close() from readExternal()");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectInputStream.StreamCallback
|
||||
public void defaultReadObject() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectInputStream.StreamCallback
|
||||
public Map readFieldsFromStream() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectInputStream.StreamCallback
|
||||
public Object readFromStream() {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
Object convertAnother = unmarshallingContext.convertAnother(externalizable, HierarchicalStreams.readClassType(hierarchicalStreamReader, ExternalizableConverter.this.mapper));
|
||||
hierarchicalStreamReader.moveUp();
|
||||
return convertAnother;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectInputStream.StreamCallback
|
||||
public void registerValidation(ObjectInputValidation objectInputValidation, int i) throws NotActiveException {
|
||||
throw new NotActiveException("stream inactive");
|
||||
}
|
||||
}, this.classLoaderReference);
|
||||
externalizable.readExternal(customObjectInputStream);
|
||||
customObjectInputStream.popCallback();
|
||||
return this.serializationMembers.callReadResolve(externalizable);
|
||||
} catch (IOException e) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Cannot externalize ");
|
||||
stringBuffer.append(requiredType.getClass());
|
||||
throw new StreamException(stringBuffer.toString(), e);
|
||||
} catch (ClassNotFoundException e2) {
|
||||
throw new ConversionException("Cannot construct type", e2);
|
||||
} catch (IllegalAccessException e3) {
|
||||
throw new ObjectAccessException("Cannot construct type", e3);
|
||||
} catch (InstantiationException e4) {
|
||||
throw new ConversionException("Cannot construct type", e4);
|
||||
} catch (NoSuchMethodException e5) {
|
||||
throw new ConversionException("Missing default constructor of type", e5);
|
||||
} catch (InvocationTargetException e6) {
|
||||
throw new ConversionException("Cannot construct type", e6);
|
||||
}
|
||||
}
|
||||
|
||||
public ExternalizableConverter(Mapper mapper, ClassLoader classLoader) {
|
||||
this(mapper, new ClassLoaderReference(classLoader));
|
||||
}
|
||||
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public ExternalizableConverter(com.thoughtworks.xstream.mapper.Mapper r2) {
|
||||
/*
|
||||
r1 = this;
|
||||
java.lang.Class r0 = com.thoughtworks.xstream.converters.reflection.ExternalizableConverter.class$com$thoughtworks$xstream$converters$reflection$ExternalizableConverter
|
||||
if (r0 != 0) goto Lc
|
||||
java.lang.String r0 = "com.thoughtworks.xstream.converters.reflection.ExternalizableConverter"
|
||||
java.lang.Class r0 = class$(r0)
|
||||
com.thoughtworks.xstream.converters.reflection.ExternalizableConverter.class$com$thoughtworks$xstream$converters$reflection$ExternalizableConverter = r0
|
||||
Lc:
|
||||
java.lang.ClassLoader r0 = r0.getClassLoader()
|
||||
r1.<init>(r2, r0)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.converters.reflection.ExternalizableConverter.<init>(com.thoughtworks.xstream.mapper.Mapper):void");
|
||||
}
|
||||
}
|
@@ -0,0 +1,186 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.core.Caching;
|
||||
import com.thoughtworks.xstream.core.JVM;
|
||||
import com.thoughtworks.xstream.core.util.OrderRetainingMap;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FieldDictionary implements Caching {
|
||||
private static final DictionaryEntry OBJECT_DICTIONARY_ENTRY;
|
||||
static /* synthetic */ Class class$java$lang$Object;
|
||||
private transient Map dictionaryEntries;
|
||||
private transient FieldUtil fieldUtil;
|
||||
private final FieldKeySorter sorter;
|
||||
|
||||
private static final class DictionaryEntry {
|
||||
private final Map keyedByFieldKey;
|
||||
private final Map keyedByFieldName;
|
||||
|
||||
public DictionaryEntry(Map map, Map map2) {
|
||||
this.keyedByFieldName = map;
|
||||
this.keyedByFieldKey = map2;
|
||||
}
|
||||
|
||||
public Map getKeyedByFieldKey() {
|
||||
return this.keyedByFieldKey;
|
||||
}
|
||||
|
||||
public Map getKeyedByFieldName() {
|
||||
return this.keyedByFieldName;
|
||||
}
|
||||
}
|
||||
|
||||
interface FieldUtil {
|
||||
boolean isSynthetic(Field field);
|
||||
}
|
||||
|
||||
static {
|
||||
Map map = Collections.EMPTY_MAP;
|
||||
OBJECT_DICTIONARY_ENTRY = new DictionaryEntry(map, map);
|
||||
}
|
||||
|
||||
public FieldDictionary() {
|
||||
this(new ImmutableFieldKeySorter());
|
||||
}
|
||||
|
||||
private DictionaryEntry buildDictionaryEntryForClass(Class cls, DictionaryEntry dictionaryEntry) {
|
||||
HashMap hashMap = new HashMap(dictionaryEntry.getKeyedByFieldName());
|
||||
OrderRetainingMap orderRetainingMap = new OrderRetainingMap(dictionaryEntry.getKeyedByFieldKey());
|
||||
Field[] declaredFields = cls.getDeclaredFields();
|
||||
if (JVM.reverseFieldDefinition()) {
|
||||
int length = declaredFields.length >> 1;
|
||||
while (true) {
|
||||
int i = length - 1;
|
||||
if (length <= 0) {
|
||||
break;
|
||||
}
|
||||
int length2 = (declaredFields.length - i) - 1;
|
||||
Field field = declaredFields[i];
|
||||
declaredFields[i] = declaredFields[length2];
|
||||
declaredFields[length2] = field;
|
||||
length = i;
|
||||
}
|
||||
}
|
||||
for (int i2 = 0; i2 < declaredFields.length; i2++) {
|
||||
Field field2 = declaredFields[i2];
|
||||
if (!this.fieldUtil.isSynthetic(field2) || !field2.getName().startsWith("$jacoco")) {
|
||||
if (!field2.isAccessible()) {
|
||||
field2.setAccessible(true);
|
||||
}
|
||||
FieldKey fieldKey = new FieldKey(field2.getName(), field2.getDeclaringClass(), i2);
|
||||
Field field3 = (Field) hashMap.get(field2.getName());
|
||||
if (field3 == null || (field3.getModifiers() & 8) != 0 || (field3 != null && (field2.getModifiers() & 8) == 0)) {
|
||||
hashMap.put(field2.getName(), field2);
|
||||
}
|
||||
orderRetainingMap.put(fieldKey, field2);
|
||||
}
|
||||
}
|
||||
return new DictionaryEntry(hashMap, this.sorter.sort(cls, orderRetainingMap));
|
||||
}
|
||||
|
||||
private Map buildMap(Class cls, boolean z) {
|
||||
LinkedList linkedList = new LinkedList();
|
||||
DictionaryEntry dictionaryEntry = null;
|
||||
while (dictionaryEntry == null) {
|
||||
Class cls2 = class$java$lang$Object;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.lang.Object");
|
||||
class$java$lang$Object = cls2;
|
||||
}
|
||||
dictionaryEntry = (cls2.equals(cls) || cls == null) ? OBJECT_DICTIONARY_ENTRY : getDictionaryEntry(cls);
|
||||
if (dictionaryEntry == null) {
|
||||
linkedList.addFirst(cls);
|
||||
cls = cls.getSuperclass();
|
||||
}
|
||||
}
|
||||
Iterator it = linkedList.iterator();
|
||||
while (it.hasNext()) {
|
||||
Class cls3 = (Class) it.next();
|
||||
dictionaryEntry = buildDictionaryEntryForClass(cls3, dictionaryEntry);
|
||||
synchronized (this) {
|
||||
DictionaryEntry dictionaryEntry2 = getDictionaryEntry(cls3);
|
||||
if (dictionaryEntry2 == null) {
|
||||
this.dictionaryEntries.put(cls3, dictionaryEntry);
|
||||
} else {
|
||||
dictionaryEntry = dictionaryEntry2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return z ? dictionaryEntry.getKeyedByFieldKey() : dictionaryEntry.getKeyedByFieldName();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized DictionaryEntry getDictionaryEntry(Class cls) {
|
||||
return (DictionaryEntry) this.dictionaryEntries.get(cls);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
this.dictionaryEntries = new HashMap();
|
||||
if (JVM.is15()) {
|
||||
try {
|
||||
this.fieldUtil = (FieldUtil) JVM.loadClassForName("com.thoughtworks.xstream.converters.reflection.FieldUtil15", true).newInstance();
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
}
|
||||
if (this.fieldUtil == null) {
|
||||
this.fieldUtil = new FieldUtil14();
|
||||
}
|
||||
}
|
||||
|
||||
public Field field(Class cls, String str, Class cls2) {
|
||||
Field fieldOrNull = fieldOrNull(cls, str, cls2);
|
||||
if (fieldOrNull != null) {
|
||||
return fieldOrNull;
|
||||
}
|
||||
throw new MissingFieldException(cls.getName(), str);
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Type inference failed for: r0v2, types: [com.thoughtworks.xstream.converters.reflection.FieldKey] */
|
||||
public Field fieldOrNull(Class cls, String str, Class cls2) {
|
||||
Map buildMap = buildMap(cls, cls2 != null);
|
||||
if (cls2 != null) {
|
||||
str = new FieldKey(str, cls2, -1);
|
||||
}
|
||||
return (Field) buildMap.get(str);
|
||||
}
|
||||
|
||||
public Iterator fieldsFor(Class cls) {
|
||||
return buildMap(cls, true).values().iterator();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.Caching
|
||||
public synchronized void flushCache() {
|
||||
this.dictionaryEntries.clear();
|
||||
if (this.sorter instanceof Caching) {
|
||||
((Caching) this.sorter).flushCache();
|
||||
}
|
||||
}
|
||||
|
||||
protected Object readResolve() {
|
||||
init();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Iterator serializableFieldsFor(Class cls) {
|
||||
return fieldsFor(cls);
|
||||
}
|
||||
|
||||
public FieldDictionary(FieldKeySorter fieldKeySorter) {
|
||||
this.sorter = fieldKeySorter;
|
||||
init();
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FieldKey {
|
||||
private final Class declaringClass;
|
||||
private final int depth;
|
||||
private final String fieldName;
|
||||
private final int order;
|
||||
|
||||
public FieldKey(String str, Class cls, int i) {
|
||||
if (str == null || cls == null) {
|
||||
throw new IllegalArgumentException("fieldName or declaringClass is null");
|
||||
}
|
||||
this.fieldName = str;
|
||||
this.declaringClass = cls;
|
||||
this.order = i;
|
||||
int i2 = 0;
|
||||
while (cls.getSuperclass() != null) {
|
||||
i2++;
|
||||
cls = cls.getSuperclass();
|
||||
}
|
||||
this.depth = i2;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof FieldKey)) {
|
||||
return false;
|
||||
}
|
||||
FieldKey fieldKey = (FieldKey) obj;
|
||||
return this.declaringClass.equals(fieldKey.declaringClass) && this.fieldName.equals(fieldKey.fieldName);
|
||||
}
|
||||
|
||||
public Class getDeclaringClass() {
|
||||
return this.declaringClass;
|
||||
}
|
||||
|
||||
public int getDepth() {
|
||||
return this.depth;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return this.fieldName;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return this.order;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (this.fieldName.hashCode() * 29) + this.declaringClass.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("FieldKey{order=");
|
||||
stringBuffer.append(this.order);
|
||||
stringBuffer.append(", writer=");
|
||||
stringBuffer.append(this.depth);
|
||||
stringBuffer.append(", declaringClass=");
|
||||
stringBuffer.append(this.declaringClass);
|
||||
stringBuffer.append(", fieldName='");
|
||||
stringBuffer.append(this.fieldName);
|
||||
stringBuffer.append("'}");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface FieldKeySorter {
|
||||
Map sort(Class cls, Map map);
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.reflection.FieldDictionary;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class FieldUtil14 implements FieldDictionary.FieldUtil {
|
||||
FieldUtil14() {
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.FieldDictionary.FieldUtil
|
||||
public boolean isSynthetic(Field field) {
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.reflection.FieldDictionary;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class FieldUtil15 implements FieldDictionary.FieldUtil {
|
||||
FieldUtil15() {
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.FieldDictionary.FieldUtil
|
||||
public boolean isSynthetic(Field field) {
|
||||
return field.isSynthetic();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ImmutableFieldKeySorter implements FieldKeySorter {
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.FieldKeySorter
|
||||
public Map sort(Class cls, Map map) {
|
||||
return map;
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.core.ClassLoaderReference;
|
||||
import com.thoughtworks.xstream.core.JVM;
|
||||
import com.thoughtworks.xstream.core.util.Types;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.mapper.Mapper;
|
||||
import java.io.Serializable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class LambdaConverter extends SerializableConverter {
|
||||
public LambdaConverter(Mapper mapper, ReflectionProvider reflectionProvider, ClassLoaderReference classLoaderReference) {
|
||||
super(mapper, reflectionProvider, classLoaderReference);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.SerializableConverter, com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return Types.isLambdaType(cls) && (JVM.canCreateDerivedObjectOutputStream() || !Serializable.class.isAssignableFrom(cls));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter, com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
if (obj instanceof Serializable) {
|
||||
super.marshal(obj, hierarchicalStreamWriter, marshallingContext);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MissingFieldException extends ObjectAccessException {
|
||||
private final String className;
|
||||
private final String fieldName;
|
||||
|
||||
public MissingFieldException(String str, String str2) {
|
||||
super("Field not found in class.");
|
||||
this.className = str;
|
||||
this.fieldName = str2;
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(str);
|
||||
stringBuffer.append(".");
|
||||
stringBuffer.append(str2);
|
||||
add("field", stringBuffer.toString());
|
||||
}
|
||||
|
||||
protected String getClassName() {
|
||||
return this.className;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return this.fieldName;
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class NativeFieldKeySorter implements FieldKeySorter {
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.FieldKeySorter
|
||||
public Map sort(Class cls, Map map) {
|
||||
TreeMap treeMap = new TreeMap(new Comparator() { // from class: com.thoughtworks.xstream.converters.reflection.NativeFieldKeySorter.1
|
||||
@Override // java.util.Comparator
|
||||
public int compare(Object obj, Object obj2) {
|
||||
FieldKey fieldKey = (FieldKey) obj;
|
||||
FieldKey fieldKey2 = (FieldKey) obj2;
|
||||
int depth = fieldKey.getDepth() - fieldKey2.getDepth();
|
||||
return depth == 0 ? fieldKey.getOrder() - fieldKey2.getOrder() : depth;
|
||||
}
|
||||
});
|
||||
treeMap.putAll(map);
|
||||
return treeMap;
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ErrorWritingException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ObjectAccessException extends ErrorWritingException {
|
||||
public ObjectAccessException(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public ObjectAccessException(String str, Throwable th) {
|
||||
super(str, th);
|
||||
}
|
||||
}
|
@@ -0,0 +1,202 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.reflection.ReflectionProvider;
|
||||
import com.thoughtworks.xstream.core.JVM;
|
||||
import com.thoughtworks.xstream.core.util.Fields;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectStreamClass;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PureJavaReflectionProvider implements ReflectionProvider {
|
||||
static /* synthetic */ Class class$java$io$Serializable;
|
||||
protected FieldDictionary fieldDictionary;
|
||||
private transient Map serializedDataCache;
|
||||
|
||||
public PureJavaReflectionProvider() {
|
||||
this(new FieldDictionary(new ImmutableFieldKeySorter()));
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Object instantiateUsingSerialization(final Class cls) {
|
||||
ObjectAccessException objectAccessException;
|
||||
Object readObject;
|
||||
try {
|
||||
synchronized (this.serializedDataCache) {
|
||||
byte[] bArr = (byte[]) this.serializedDataCache.get(cls);
|
||||
if (bArr == null) {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
|
||||
dataOutputStream.writeShort(-21267);
|
||||
dataOutputStream.writeShort(5);
|
||||
dataOutputStream.writeByte(115);
|
||||
dataOutputStream.writeByte(114);
|
||||
dataOutputStream.writeUTF(cls.getName());
|
||||
dataOutputStream.writeLong(ObjectStreamClass.lookup(cls).getSerialVersionUID());
|
||||
dataOutputStream.writeByte(2);
|
||||
dataOutputStream.writeShort(0);
|
||||
dataOutputStream.writeByte(120);
|
||||
dataOutputStream.writeByte(112);
|
||||
bArr = byteArrayOutputStream.toByteArray();
|
||||
this.serializedDataCache.put(cls, bArr);
|
||||
}
|
||||
readObject = new ObjectInputStream(new ByteArrayInputStream(bArr)) { // from class: com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.1
|
||||
@Override // java.io.ObjectInputStream
|
||||
protected Class resolveClass(ObjectStreamClass objectStreamClass) throws IOException, ClassNotFoundException {
|
||||
return Class.forName(objectStreamClass.getName(), false, cls.getClassLoader());
|
||||
}
|
||||
}.readObject();
|
||||
}
|
||||
return readObject;
|
||||
} catch (IOException e) {
|
||||
objectAccessException = new ObjectAccessException("Cannot create type by JDK serialization", e);
|
||||
objectAccessException.add("construction-type", cls.getName());
|
||||
throw objectAccessException;
|
||||
} catch (ClassNotFoundException e2) {
|
||||
objectAccessException = new ObjectAccessException("Cannot find class", e2);
|
||||
objectAccessException.add("construction-type", cls.getName());
|
||||
throw objectAccessException;
|
||||
}
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
init();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public boolean fieldDefinedInClass(String str, Class cls) {
|
||||
Field fieldOrNull = this.fieldDictionary.fieldOrNull(cls, str, null);
|
||||
return fieldOrNull != null && fieldModifiersSupported(fieldOrNull);
|
||||
}
|
||||
|
||||
protected boolean fieldModifiersSupported(Field field) {
|
||||
int modifiers = field.getModifiers();
|
||||
return (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers)) ? false : true;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public Field getField(Class cls, String str) {
|
||||
return this.fieldDictionary.field(cls, str, null);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public Field getFieldOrNull(Class cls, String str) {
|
||||
return this.fieldDictionary.fieldOrNull(cls, str, null);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public Class getFieldType(Object obj, String str, Class cls) {
|
||||
return this.fieldDictionary.field(obj.getClass(), str, cls).getType();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
this.serializedDataCache = new WeakHashMap();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public Object newInstance(Class cls) {
|
||||
ObjectAccessException objectAccessException;
|
||||
ObjectAccessException objectAccessException2;
|
||||
Class cls2;
|
||||
try {
|
||||
for (Constructor<?> constructor : cls.getDeclaredConstructors()) {
|
||||
if (constructor.getParameterTypes().length == 0) {
|
||||
if (!constructor.isAccessible()) {
|
||||
constructor.setAccessible(true);
|
||||
}
|
||||
return constructor.newInstance(new Object[0]);
|
||||
}
|
||||
}
|
||||
if (class$java$io$Serializable == null) {
|
||||
cls2 = class$("java.io.Serializable");
|
||||
class$java$io$Serializable = cls2;
|
||||
} else {
|
||||
cls2 = class$java$io$Serializable;
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
objectAccessException2 = new ObjectAccessException("Cannot construct type", e);
|
||||
objectAccessException = objectAccessException2;
|
||||
} catch (InstantiationException e2) {
|
||||
objectAccessException2 = new ObjectAccessException("Cannot construct type", e2);
|
||||
objectAccessException = objectAccessException2;
|
||||
} catch (InvocationTargetException e3) {
|
||||
if (e3.getTargetException() instanceof RuntimeException) {
|
||||
throw ((RuntimeException) e3.getTargetException());
|
||||
}
|
||||
if (e3.getTargetException() instanceof Error) {
|
||||
throw ((Error) e3.getTargetException());
|
||||
}
|
||||
objectAccessException = new ObjectAccessException("Constructor for type threw an exception", e3.getTargetException());
|
||||
}
|
||||
if (cls2.isAssignableFrom(cls)) {
|
||||
return instantiateUsingSerialization(cls);
|
||||
}
|
||||
objectAccessException = new ObjectAccessException("Cannot construct type as it does not have a no-args constructor");
|
||||
objectAccessException.add("construction-type", cls.getName());
|
||||
throw objectAccessException;
|
||||
}
|
||||
|
||||
public void setFieldDictionary(FieldDictionary fieldDictionary) {
|
||||
this.fieldDictionary = fieldDictionary;
|
||||
}
|
||||
|
||||
protected void validateFieldAccess(Field field) {
|
||||
if (Modifier.isFinal(field.getModifiers())) {
|
||||
if (JVM.isVersion(5)) {
|
||||
if (field.isAccessible()) {
|
||||
return;
|
||||
}
|
||||
field.setAccessible(true);
|
||||
} else {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Invalid final field ");
|
||||
stringBuffer.append(field.getDeclaringClass().getName());
|
||||
stringBuffer.append(".");
|
||||
stringBuffer.append(field.getName());
|
||||
throw new ObjectAccessException(stringBuffer.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public void visitSerializableFields(Object obj, ReflectionProvider.Visitor visitor) {
|
||||
Iterator fieldsFor = this.fieldDictionary.fieldsFor(obj.getClass());
|
||||
while (fieldsFor.hasNext()) {
|
||||
Field field = (Field) fieldsFor.next();
|
||||
if (fieldModifiersSupported(field)) {
|
||||
validateFieldAccess(field);
|
||||
visitor.visit(field.getName(), field.getType(), field.getDeclaringClass(), Fields.read(field, obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public void writeField(Object obj, String str, Object obj2, Class cls) {
|
||||
Field field = this.fieldDictionary.field(obj.getClass(), str, cls);
|
||||
validateFieldAccess(field);
|
||||
Fields.write(field, obj, obj2);
|
||||
}
|
||||
|
||||
public PureJavaReflectionProvider(FieldDictionary fieldDictionary) {
|
||||
this.fieldDictionary = fieldDictionary;
|
||||
init();
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.mapper.Mapper;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ReflectionConverter extends AbstractReflectionConverter {
|
||||
private Class type;
|
||||
|
||||
public ReflectionConverter(Mapper mapper, ReflectionProvider reflectionProvider) {
|
||||
super(mapper, reflectionProvider);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
Class cls2 = this.type;
|
||||
return ((cls2 != null && cls2 == cls) || (this.type == null && cls != null)) && canAccess(cls);
|
||||
}
|
||||
|
||||
public ReflectionConverter(Mapper mapper, ReflectionProvider reflectionProvider, Class cls) {
|
||||
this(mapper, reflectionProvider);
|
||||
this.type = cls;
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ReflectionProvider {
|
||||
|
||||
public interface Visitor {
|
||||
void visit(String str, Class cls, Class cls2, Object obj);
|
||||
}
|
||||
|
||||
boolean fieldDefinedInClass(String str, Class cls);
|
||||
|
||||
Field getField(Class cls, String str);
|
||||
|
||||
Field getFieldOrNull(Class cls, String str);
|
||||
|
||||
Class getFieldType(Object obj, String str, Class cls);
|
||||
|
||||
Object newInstance(Class cls);
|
||||
|
||||
void visitSerializableFields(Object obj, Visitor visitor);
|
||||
|
||||
void writeField(Object obj, String str, Object obj2, Class cls);
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.reflection.ReflectionProvider;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ReflectionProviderWrapper implements ReflectionProvider {
|
||||
protected final ReflectionProvider wrapped;
|
||||
|
||||
public ReflectionProviderWrapper(ReflectionProvider reflectionProvider) {
|
||||
this.wrapped = reflectionProvider;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public boolean fieldDefinedInClass(String str, Class cls) {
|
||||
return this.wrapped.fieldDefinedInClass(str, cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public Field getField(Class cls, String str) {
|
||||
return this.wrapped.getField(cls, str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public Field getFieldOrNull(Class cls, String str) {
|
||||
return this.wrapped.getFieldOrNull(cls, str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public Class getFieldType(Object obj, String str, Class cls) {
|
||||
return this.wrapped.getFieldType(obj, str, cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public Object newInstance(Class cls) {
|
||||
return this.wrapped.newInstance(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public void visitSerializableFields(Object obj, ReflectionProvider.Visitor visitor) {
|
||||
this.wrapped.visitSerializableFields(obj, visitor);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public void writeField(Object obj, String str, Object obj2, Class cls) {
|
||||
this.wrapped.writeField(obj, str, obj2, cls);
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SelfStreamingInstanceChecker extends com.thoughtworks.xstream.core.util.SelfStreamingInstanceChecker {
|
||||
public SelfStreamingInstanceChecker(Converter converter, Object obj) {
|
||||
super(converter, obj);
|
||||
}
|
||||
}
|
@@ -0,0 +1,449 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ConversionException;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.reflection.ReflectionProvider;
|
||||
import com.thoughtworks.xstream.core.ClassLoaderReference;
|
||||
import com.thoughtworks.xstream.core.JVM;
|
||||
import com.thoughtworks.xstream.core.util.CustomObjectInputStream;
|
||||
import com.thoughtworks.xstream.core.util.CustomObjectOutputStream;
|
||||
import com.thoughtworks.xstream.core.util.Fields;
|
||||
import com.thoughtworks.xstream.core.util.HierarchicalStreams;
|
||||
import com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.mapper.Mapper;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectInputValidation;
|
||||
import java.io.ObjectStreamClass;
|
||||
import java.io.ObjectStreamField;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SerializableConverter extends AbstractReflectionConverter {
|
||||
private static final String ATTRIBUTE_CLASS = "class";
|
||||
private static final String ATTRIBUTE_NAME = "name";
|
||||
private static final String ATTRIBUTE_SERIALIZATION = "serialization";
|
||||
private static final String ATTRIBUTE_VALUE_CUSTOM = "custom";
|
||||
private static final String ELEMENT_DEFAULT = "default";
|
||||
private static final String ELEMENT_FIELD = "field";
|
||||
private static final String ELEMENT_FIELDS = "fields";
|
||||
private static final String ELEMENT_NULL = "null";
|
||||
private static final String ELEMENT_UNSERIALIZABLE_PARENTS = "unserializable-parents";
|
||||
static /* synthetic */ Class class$java$io$Serializable;
|
||||
static /* synthetic */ Class class$java$lang$Object;
|
||||
private final ClassLoaderReference classLoaderReference;
|
||||
|
||||
private static class UnserializableParentsReflectionProvider extends ReflectionProviderWrapper {
|
||||
public UnserializableParentsReflectionProvider(ReflectionProvider reflectionProvider) {
|
||||
super(reflectionProvider);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProviderWrapper, com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public void visitSerializableFields(Object obj, final ReflectionProvider.Visitor visitor) {
|
||||
this.wrapped.visitSerializableFields(obj, new ReflectionProvider.Visitor() { // from class: com.thoughtworks.xstream.converters.reflection.SerializableConverter.UnserializableParentsReflectionProvider.1
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.ReflectionProvider.Visitor
|
||||
public void visit(String str, Class cls, Class cls2, Object obj2) {
|
||||
Class cls3 = SerializableConverter.class$java$io$Serializable;
|
||||
if (cls3 == null) {
|
||||
cls3 = SerializableConverter.class$("java.io.Serializable");
|
||||
SerializableConverter.class$java$io$Serializable = cls3;
|
||||
}
|
||||
if (cls3.isAssignableFrom(cls2)) {
|
||||
return;
|
||||
}
|
||||
visitor.visit(str, cls, cls2, obj2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public SerializableConverter(Mapper mapper, ReflectionProvider reflectionProvider, ClassLoaderReference classLoaderReference) {
|
||||
super(mapper, new UnserializableParentsReflectionProvider(reflectionProvider));
|
||||
this.classLoaderReference = classLoaderReference;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSerializable(Class cls) {
|
||||
if (cls == null) {
|
||||
return false;
|
||||
}
|
||||
Class cls2 = class$java$io$Serializable;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.io.Serializable");
|
||||
class$java$io$Serializable = cls2;
|
||||
}
|
||||
if (!cls2.isAssignableFrom(cls) || cls.isInterface()) {
|
||||
return false;
|
||||
}
|
||||
if (!this.serializationMembers.supportsReadObject(cls, true) && !this.serializationMembers.supportsWriteObject(cls, true)) {
|
||||
return false;
|
||||
}
|
||||
Iterator it = hierarchyFor(cls).iterator();
|
||||
while (it.hasNext()) {
|
||||
Class cls3 = class$java$io$Serializable;
|
||||
if (cls3 == null) {
|
||||
cls3 = class$("java.io.Serializable");
|
||||
class$java$io$Serializable = cls3;
|
||||
}
|
||||
if (!cls3.isAssignableFrom((Class) it.next())) {
|
||||
return canAccess(cls);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public Object readField(ObjectStreamField objectStreamField, Class cls, Object obj) {
|
||||
return Fields.read(Fields.find(cls, objectStreamField.getName()), obj);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return JVM.canCreateDerivedObjectOutputStream() && isSerializable(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter
|
||||
public void doMarshal(final Object obj, final HierarchicalStreamWriter hierarchicalStreamWriter, final MarshallingContext marshallingContext) {
|
||||
Class cls;
|
||||
String aliasForSystemAttribute;
|
||||
String aliasForSystemAttribute2;
|
||||
String aliasForSystemAttribute3 = this.mapper.aliasForSystemAttribute(ATTRIBUTE_SERIALIZATION);
|
||||
if (aliasForSystemAttribute3 != null) {
|
||||
hierarchicalStreamWriter.addAttribute(aliasForSystemAttribute3, ATTRIBUTE_VALUE_CUSTOM);
|
||||
}
|
||||
final Class[] clsArr = new Class[1];
|
||||
final boolean[] zArr = {false};
|
||||
CustomObjectOutputStream.StreamCallback streamCallback = new CustomObjectOutputStream.StreamCallback() { // from class: com.thoughtworks.xstream.converters.reflection.SerializableConverter.1
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectOutputStream.StreamCallback
|
||||
public void close() {
|
||||
throw new UnsupportedOperationException("Objects are not allowed to call ObjectOutputStream.close() from writeObject()");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectOutputStream.StreamCallback
|
||||
public void defaultWriteObject() {
|
||||
String aliasForSystemAttribute4;
|
||||
ObjectStreamClass lookup = ObjectStreamClass.lookup(clsArr[0]);
|
||||
if (lookup == null) {
|
||||
return;
|
||||
}
|
||||
boolean z = false;
|
||||
for (ObjectStreamField objectStreamField : lookup.getFields()) {
|
||||
Object readField = SerializableConverter.this.readField(objectStreamField, clsArr[0], obj);
|
||||
if (readField != null) {
|
||||
if (!zArr[0]) {
|
||||
hierarchicalStreamWriter.startNode(SerializableConverter.this.mapper.serializedClass(clsArr[0]));
|
||||
zArr[0] = true;
|
||||
}
|
||||
if (!z) {
|
||||
hierarchicalStreamWriter.startNode("default");
|
||||
z = true;
|
||||
}
|
||||
if (SerializableConverter.this.mapper.shouldSerializeMember(clsArr[0], objectStreamField.getName())) {
|
||||
Class<?> cls2 = readField.getClass();
|
||||
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, SerializableConverter.this.mapper.serializedMember(obj.getClass(), objectStreamField.getName()), cls2);
|
||||
if (!cls2.equals(SerializableConverter.this.mapper.defaultImplementationOf(objectStreamField.getType())) && (aliasForSystemAttribute4 = SerializableConverter.this.mapper.aliasForSystemAttribute(SerializableConverter.ATTRIBUTE_CLASS)) != null) {
|
||||
hierarchicalStreamWriter.addAttribute(aliasForSystemAttribute4, SerializableConverter.this.mapper.serializedClass(cls2));
|
||||
}
|
||||
marshallingContext.convertAnother(readField);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (zArr[0] && !z) {
|
||||
hierarchicalStreamWriter.startNode("default");
|
||||
hierarchicalStreamWriter.endNode();
|
||||
} else if (z) {
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectOutputStream.StreamCallback
|
||||
public void flush() {
|
||||
hierarchicalStreamWriter.flush();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectOutputStream.StreamCallback
|
||||
public void writeFieldsToStream(Map map) {
|
||||
String aliasForSystemAttribute4;
|
||||
ObjectStreamClass lookup = ObjectStreamClass.lookup(clsArr[0]);
|
||||
hierarchicalStreamWriter.startNode("default");
|
||||
for (String str : map.keySet()) {
|
||||
if (SerializableConverter.this.mapper.shouldSerializeMember(clsArr[0], str)) {
|
||||
ObjectStreamField field = lookup.getField(str);
|
||||
Object obj2 = map.get(str);
|
||||
if (field == null) {
|
||||
throw new MissingFieldException(obj2.getClass().getName(), str);
|
||||
}
|
||||
if (obj2 != null) {
|
||||
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, SerializableConverter.this.mapper.serializedMember(obj.getClass(), str), obj2.getClass());
|
||||
if (field.getType() != obj2.getClass() && !field.getType().isPrimitive() && (aliasForSystemAttribute4 = SerializableConverter.this.mapper.aliasForSystemAttribute(SerializableConverter.ATTRIBUTE_CLASS)) != null) {
|
||||
hierarchicalStreamWriter.addAttribute(aliasForSystemAttribute4, SerializableConverter.this.mapper.serializedClass(obj2.getClass()));
|
||||
}
|
||||
marshallingContext.convertAnother(obj2);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
}
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectOutputStream.StreamCallback
|
||||
public void writeToStream(Object obj2) {
|
||||
if (obj2 == null) {
|
||||
hierarchicalStreamWriter.startNode(SerializableConverter.ELEMENT_NULL);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
} else {
|
||||
ExtendedHierarchicalStreamWriterHelper.startNode(hierarchicalStreamWriter, SerializableConverter.this.mapper.serializedClass(obj2.getClass()), obj2.getClass());
|
||||
marshallingContext.convertAnother(obj2);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
};
|
||||
try {
|
||||
Iterator it = hierarchyFor(obj.getClass()).iterator();
|
||||
boolean z = false;
|
||||
while (it.hasNext()) {
|
||||
clsArr[0] = (Class) it.next();
|
||||
if (class$java$io$Serializable == null) {
|
||||
cls = class$("java.io.Serializable");
|
||||
class$java$io$Serializable = cls;
|
||||
} else {
|
||||
cls = class$java$io$Serializable;
|
||||
}
|
||||
if (cls.isAssignableFrom(clsArr[0])) {
|
||||
if (z) {
|
||||
marshalUnserializableParent(hierarchicalStreamWriter, marshallingContext, obj);
|
||||
z = false;
|
||||
}
|
||||
if (this.serializationMembers.supportsWriteObject(clsArr[0], false)) {
|
||||
zArr[0] = true;
|
||||
hierarchicalStreamWriter.startNode(this.mapper.serializedClass(clsArr[0]));
|
||||
if (clsArr[0] != this.mapper.defaultImplementationOf(clsArr[0]) && (aliasForSystemAttribute = this.mapper.aliasForSystemAttribute(ATTRIBUTE_CLASS)) != null) {
|
||||
hierarchicalStreamWriter.addAttribute(aliasForSystemAttribute, clsArr[0].getName());
|
||||
}
|
||||
CustomObjectOutputStream customObjectOutputStream = CustomObjectOutputStream.getInstance(marshallingContext, streamCallback);
|
||||
this.serializationMembers.callWriteObject(clsArr[0], obj, customObjectOutputStream);
|
||||
customObjectOutputStream.popCallback();
|
||||
hierarchicalStreamWriter.endNode();
|
||||
} else if (this.serializationMembers.supportsReadObject(clsArr[0], false)) {
|
||||
zArr[0] = true;
|
||||
hierarchicalStreamWriter.startNode(this.mapper.serializedClass(clsArr[0]));
|
||||
if (clsArr[0] != this.mapper.defaultImplementationOf(clsArr[0]) && (aliasForSystemAttribute2 = this.mapper.aliasForSystemAttribute(ATTRIBUTE_CLASS)) != null) {
|
||||
hierarchicalStreamWriter.addAttribute(aliasForSystemAttribute2, clsArr[0].getName());
|
||||
}
|
||||
streamCallback.defaultWriteObject();
|
||||
hierarchicalStreamWriter.endNode();
|
||||
} else {
|
||||
zArr[0] = false;
|
||||
streamCallback.defaultWriteObject();
|
||||
if (zArr[0]) {
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new StreamException("Cannot write defaults", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doMarshalConditionally(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
if (isSerializable(obj.getClass())) {
|
||||
doMarshal(obj, hierarchicalStreamWriter, marshallingContext);
|
||||
} else {
|
||||
super.doMarshal(obj, hierarchicalStreamWriter, marshallingContext);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter
|
||||
public Object doUnmarshal(final Object obj, final HierarchicalStreamReader hierarchicalStreamReader, final UnmarshallingContext unmarshallingContext) {
|
||||
final Class[] clsArr = new Class[1];
|
||||
String aliasForSystemAttribute = this.mapper.aliasForSystemAttribute(ATTRIBUTE_SERIALIZATION);
|
||||
if (aliasForSystemAttribute != null && !ATTRIBUTE_VALUE_CUSTOM.equals(hierarchicalStreamReader.getAttribute(aliasForSystemAttribute))) {
|
||||
throw new ConversionException("Cannot deserialize object with new readObject()/writeObject() methods");
|
||||
}
|
||||
CustomObjectInputStream.StreamCallback streamCallback = new CustomObjectInputStream.StreamCallback() { // from class: com.thoughtworks.xstream.converters.reflection.SerializableConverter.2
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectInputStream.StreamCallback
|
||||
public void close() {
|
||||
throw new UnsupportedOperationException("Objects are not allowed to call ObjectInputStream.close() from readObject()");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectInputStream.StreamCallback
|
||||
public void defaultReadObject() {
|
||||
Class defaultImplementationOf;
|
||||
if (SerializableConverter.this.serializationMembers.getSerializablePersistentFields(clsArr[0]) != null) {
|
||||
readFieldsFromStream();
|
||||
return;
|
||||
}
|
||||
if (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
if (!hierarchicalStreamReader.getNodeName().equals("default")) {
|
||||
throw new ConversionException("Expected <default/> element in readObject() stream");
|
||||
}
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
String realMember = SerializableConverter.this.mapper.realMember(clsArr[0], hierarchicalStreamReader.getNodeName());
|
||||
if (SerializableConverter.this.mapper.shouldSerializeMember(clsArr[0], realMember)) {
|
||||
String readClassAttribute = HierarchicalStreams.readClassAttribute(hierarchicalStreamReader, SerializableConverter.this.mapper);
|
||||
if (readClassAttribute != null) {
|
||||
defaultImplementationOf = SerializableConverter.this.mapper.realClass(readClassAttribute);
|
||||
} else {
|
||||
SerializableConverter serializableConverter = SerializableConverter.this;
|
||||
defaultImplementationOf = serializableConverter.mapper.defaultImplementationOf(serializableConverter.reflectionProvider.getFieldType(obj, realMember, clsArr[0]));
|
||||
}
|
||||
SerializableConverter.this.reflectionProvider.writeField(obj, realMember, unmarshallingContext.convertAnother(obj, defaultImplementationOf), clsArr[0]);
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectInputStream.StreamCallback
|
||||
public Map readFieldsFromStream() {
|
||||
Class type;
|
||||
HashMap hashMap = new HashMap();
|
||||
hierarchicalStreamReader.moveDown();
|
||||
if (hierarchicalStreamReader.getNodeName().equals(SerializableConverter.ELEMENT_FIELDS)) {
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
if (!hierarchicalStreamReader.getNodeName().equals(SerializableConverter.ELEMENT_FIELD)) {
|
||||
throw new ConversionException("Expected <field/> element inside <field/>");
|
||||
}
|
||||
hashMap.put(hierarchicalStreamReader.getAttribute("name"), unmarshallingContext.convertAnother(obj, SerializableConverter.this.mapper.realClass(hierarchicalStreamReader.getAttribute(SerializableConverter.ATTRIBUTE_CLASS))));
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
} else {
|
||||
if (!hierarchicalStreamReader.getNodeName().equals("default")) {
|
||||
throw new ConversionException("Expected <fields/> or <default/> element when calling ObjectInputStream.readFields()");
|
||||
}
|
||||
ObjectStreamClass lookup = ObjectStreamClass.lookup(clsArr[0]);
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
String realMember = SerializableConverter.this.mapper.realMember(clsArr[0], hierarchicalStreamReader.getNodeName());
|
||||
if (SerializableConverter.this.mapper.shouldSerializeMember(clsArr[0], realMember)) {
|
||||
String readClassAttribute = HierarchicalStreams.readClassAttribute(hierarchicalStreamReader, SerializableConverter.this.mapper);
|
||||
if (readClassAttribute != null) {
|
||||
type = SerializableConverter.this.mapper.realClass(readClassAttribute);
|
||||
} else {
|
||||
ObjectStreamField field = lookup.getField(realMember);
|
||||
if (field == null) {
|
||||
throw new MissingFieldException(clsArr[0].getName(), realMember);
|
||||
}
|
||||
type = field.getType();
|
||||
}
|
||||
hashMap.put(realMember, unmarshallingContext.convertAnother(obj, type));
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectInputStream.StreamCallback
|
||||
public Object readFromStream() {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
Object convertAnother = unmarshallingContext.convertAnother(obj, HierarchicalStreams.readClassType(hierarchicalStreamReader, SerializableConverter.this.mapper));
|
||||
hierarchicalStreamReader.moveUp();
|
||||
return convertAnother;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.util.CustomObjectInputStream.StreamCallback
|
||||
public void registerValidation(final ObjectInputValidation objectInputValidation, int i) {
|
||||
unmarshallingContext.addCompletionCallback(new Runnable() { // from class: com.thoughtworks.xstream.converters.reflection.SerializableConverter.2.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
objectInputValidation.validateObject();
|
||||
} catch (InvalidObjectException e) {
|
||||
throw new ObjectAccessException("Cannot validate object", e);
|
||||
}
|
||||
}
|
||||
}, i);
|
||||
}
|
||||
};
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
String nodeName = hierarchicalStreamReader.getNodeName();
|
||||
if (nodeName.equals(ELEMENT_UNSERIALIZABLE_PARENTS)) {
|
||||
super.doUnmarshal(obj, hierarchicalStreamReader, unmarshallingContext);
|
||||
} else {
|
||||
String readClassAttribute = HierarchicalStreams.readClassAttribute(hierarchicalStreamReader, this.mapper);
|
||||
if (readClassAttribute == null) {
|
||||
Mapper mapper = this.mapper;
|
||||
clsArr[0] = mapper.defaultImplementationOf(mapper.realClass(nodeName));
|
||||
} else {
|
||||
clsArr[0] = this.mapper.realClass(readClassAttribute);
|
||||
}
|
||||
if (this.serializationMembers.supportsReadObject(clsArr[0], false)) {
|
||||
CustomObjectInputStream customObjectInputStream = CustomObjectInputStream.getInstance(unmarshallingContext, streamCallback, this.classLoaderReference);
|
||||
this.serializationMembers.callReadObject(clsArr[0], obj, customObjectInputStream);
|
||||
customObjectInputStream.popCallback();
|
||||
} else {
|
||||
try {
|
||||
streamCallback.defaultReadObject();
|
||||
} catch (IOException e) {
|
||||
throw new StreamException("Cannot read defaults", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
protected Object doUnmarshalConditionally(Object obj, HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
return isSerializable(obj.getClass()) ? doUnmarshal(obj, hierarchicalStreamReader, unmarshallingContext) : super.doUnmarshal(obj, hierarchicalStreamReader, unmarshallingContext);
|
||||
}
|
||||
|
||||
protected List hierarchyFor(Class cls) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
while (true) {
|
||||
Class cls2 = class$java$lang$Object;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.lang.Object");
|
||||
class$java$lang$Object = cls2;
|
||||
}
|
||||
if (cls == cls2 || cls == null) {
|
||||
break;
|
||||
}
|
||||
arrayList.add(cls);
|
||||
cls = cls.getSuperclass();
|
||||
}
|
||||
Collections.reverse(arrayList);
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
protected void marshalUnserializableParent(HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext, Object obj) {
|
||||
hierarchicalStreamWriter.startNode(ELEMENT_UNSERIALIZABLE_PARENTS);
|
||||
super.doMarshal(obj, hierarchicalStreamWriter, marshallingContext);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
public SerializableConverter(Mapper mapper, ReflectionProvider reflectionProvider, ClassLoader classLoader) {
|
||||
this(mapper, reflectionProvider, new ClassLoaderReference(classLoader));
|
||||
}
|
||||
|
||||
public SerializableConverter(Mapper mapper, ReflectionProvider reflectionProvider) {
|
||||
this(mapper, new UnserializableParentsReflectionProvider(reflectionProvider), new ClassLoaderReference(null));
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.core.Caching;
|
||||
import com.thoughtworks.xstream.core.util.SerializationMembers;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SerializationMethodInvoker implements Caching {
|
||||
SerializationMembers serializationMembers = new SerializationMembers();
|
||||
|
||||
public void callReadObject(Class cls, Object obj, ObjectInputStream objectInputStream) {
|
||||
this.serializationMembers.callReadObject(cls, obj, objectInputStream);
|
||||
}
|
||||
|
||||
public Object callReadResolve(Object obj) {
|
||||
return this.serializationMembers.callReadResolve(obj);
|
||||
}
|
||||
|
||||
public void callWriteObject(Class cls, Object obj, ObjectOutputStream objectOutputStream) {
|
||||
this.serializationMembers.callWriteObject(cls, obj, objectOutputStream);
|
||||
}
|
||||
|
||||
public Object callWriteReplace(Object obj) {
|
||||
return this.serializationMembers.callWriteReplace(obj);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.Caching
|
||||
public void flushCache() {
|
||||
this.serializationMembers.flushCache();
|
||||
}
|
||||
|
||||
public boolean supportsReadObject(Class cls, boolean z) {
|
||||
return this.serializationMembers.supportsReadObject(cls, z);
|
||||
}
|
||||
|
||||
public boolean supportsWriteObject(Class cls, boolean z) {
|
||||
return this.serializationMembers.supportsWriteObject(cls, z);
|
||||
}
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ConversionException;
|
||||
import com.thoughtworks.xstream.core.Caching;
|
||||
import com.thoughtworks.xstream.core.util.OrderRetainingMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SortableFieldKeySorter implements FieldKeySorter, Caching {
|
||||
private static final FieldKey[] EMPTY_FIELD_KEY_ARRAY = new FieldKey[0];
|
||||
private final Map map = new HashMap();
|
||||
|
||||
@Override // com.thoughtworks.xstream.core.Caching
|
||||
public void flushCache() {
|
||||
this.map.clear();
|
||||
}
|
||||
|
||||
public void registerFieldOrder(Class cls, String[] strArr) {
|
||||
this.map.put(cls, new FieldComparator(cls, strArr));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.FieldKeySorter
|
||||
public Map sort(Class cls, Map map) {
|
||||
if (!this.map.containsKey(cls)) {
|
||||
return map;
|
||||
}
|
||||
OrderRetainingMap orderRetainingMap = new OrderRetainingMap();
|
||||
FieldKey[] fieldKeyArr = (FieldKey[]) map.keySet().toArray(EMPTY_FIELD_KEY_ARRAY);
|
||||
Arrays.sort(fieldKeyArr, (Comparator) this.map.get(cls));
|
||||
for (int i = 0; i < fieldKeyArr.length; i++) {
|
||||
orderRetainingMap.put(fieldKeyArr[i], map.get(fieldKeyArr[i]));
|
||||
}
|
||||
return orderRetainingMap;
|
||||
}
|
||||
|
||||
private class FieldComparator implements Comparator {
|
||||
private final String[] fieldOrder;
|
||||
private final Class type;
|
||||
|
||||
public FieldComparator(Class cls, String[] strArr) {
|
||||
this.type = cls;
|
||||
this.fieldOrder = strArr;
|
||||
}
|
||||
|
||||
public int compare(String str, String str2) {
|
||||
int i = 0;
|
||||
int i2 = -1;
|
||||
int i3 = -1;
|
||||
while (true) {
|
||||
String[] strArr = this.fieldOrder;
|
||||
if (i >= strArr.length) {
|
||||
break;
|
||||
}
|
||||
if (strArr[i].equals(str)) {
|
||||
i2 = i;
|
||||
}
|
||||
if (this.fieldOrder[i].equals(str2)) {
|
||||
i3 = i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (i2 != -1 && i3 != -1) {
|
||||
return i2 - i3;
|
||||
}
|
||||
ConversionException conversionException = new ConversionException("Incomplete list of serialized fields for type");
|
||||
conversionException.add("sort-type", this.type.getName());
|
||||
throw conversionException;
|
||||
}
|
||||
|
||||
@Override // java.util.Comparator
|
||||
public int compare(Object obj, Object obj2) {
|
||||
return compare(((FieldKey) obj).getFieldName(), ((FieldKey) obj2).getFieldName());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Sun14ReflectionProvider extends SunUnsafeReflectionProvider {
|
||||
public Sun14ReflectionProvider() {
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
init();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sun14ReflectionProvider(FieldDictionary fieldDictionary) {
|
||||
super(fieldDictionary);
|
||||
}
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ConversionException;
|
||||
import com.thoughtworks.xstream.converters.ErrorWritingException;
|
||||
import java.lang.reflect.Field;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SunLimitedUnsafeReflectionProvider extends PureJavaReflectionProvider {
|
||||
static /* synthetic */ Class class$java$lang$Void;
|
||||
static /* synthetic */ Class class$sun$misc$Unsafe;
|
||||
protected static final Exception exception;
|
||||
protected static final Unsafe unsafe;
|
||||
|
||||
static {
|
||||
Class cls;
|
||||
Unsafe unsafe2 = null;
|
||||
try {
|
||||
if (class$sun$misc$Unsafe == null) {
|
||||
cls = class$("sun.misc.Unsafe");
|
||||
class$sun$misc$Unsafe = cls;
|
||||
} else {
|
||||
cls = class$sun$misc$Unsafe;
|
||||
}
|
||||
Field declaredField = cls.getDeclaredField("theUnsafe");
|
||||
declaredField.setAccessible(true);
|
||||
Unsafe unsafe3 = (Unsafe) declaredField.get(null);
|
||||
e = null;
|
||||
unsafe2 = unsafe3;
|
||||
} catch (IllegalAccessException e) {
|
||||
e = e;
|
||||
} catch (IllegalArgumentException e2) {
|
||||
e = e2;
|
||||
} catch (NoSuchFieldException e3) {
|
||||
e = e3;
|
||||
} catch (SecurityException e4) {
|
||||
e = e4;
|
||||
}
|
||||
exception = e;
|
||||
unsafe = unsafe2;
|
||||
}
|
||||
|
||||
public SunLimitedUnsafeReflectionProvider() {
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
init();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider, com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public Object newInstance(Class cls) {
|
||||
ErrorWritingException conversionException;
|
||||
Exception exc = exception;
|
||||
if (exc != null) {
|
||||
ObjectAccessException objectAccessException = new ObjectAccessException("Cannot construct type", exc);
|
||||
objectAccessException.add("construction-type", cls.getName());
|
||||
throw objectAccessException;
|
||||
}
|
||||
if (cls != Void.TYPE) {
|
||||
Class cls2 = class$java$lang$Void;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.lang.Void");
|
||||
class$java$lang$Void = cls2;
|
||||
}
|
||||
if (cls != cls2) {
|
||||
try {
|
||||
return unsafe.allocateInstance(cls);
|
||||
} catch (IllegalArgumentException e) {
|
||||
conversionException = new ObjectAccessException("Cannot construct type", e);
|
||||
} catch (InstantiationException e2) {
|
||||
conversionException = new ConversionException("Cannot construct type", e2);
|
||||
} catch (SecurityException e3) {
|
||||
conversionException = new ObjectAccessException("Cannot construct type", e3);
|
||||
}
|
||||
}
|
||||
}
|
||||
conversionException = new ConversionException("Type void cannot have an instance");
|
||||
conversionException.add("construction-type", cls.getName());
|
||||
throw conversionException;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider
|
||||
protected void validateFieldAccess(Field field) {
|
||||
}
|
||||
|
||||
public SunLimitedUnsafeReflectionProvider(FieldDictionary fieldDictionary) {
|
||||
super(fieldDictionary);
|
||||
}
|
||||
}
|
@@ -0,0 +1,112 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SunUnsafeReflectionProvider extends SunLimitedUnsafeReflectionProvider {
|
||||
private transient Map fieldOffsetCache;
|
||||
|
||||
public SunUnsafeReflectionProvider() {
|
||||
}
|
||||
|
||||
private synchronized long getFieldOffset(Field field) {
|
||||
Long l;
|
||||
l = (Long) this.fieldOffsetCache.get(field);
|
||||
if (l == null) {
|
||||
l = new Long(SunLimitedUnsafeReflectionProvider.unsafe.objectFieldOffset(field));
|
||||
this.fieldOffsetCache.put(field, l);
|
||||
}
|
||||
return l.longValue();
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
init();
|
||||
return this;
|
||||
}
|
||||
|
||||
private void write(Field field, Object obj, Object obj2) {
|
||||
Exception exc = SunLimitedUnsafeReflectionProvider.exception;
|
||||
if (exc != null) {
|
||||
ObjectAccessException objectAccessException = new ObjectAccessException("Cannot set field", exc);
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(obj.getClass());
|
||||
stringBuffer.append(".");
|
||||
stringBuffer.append(field.getName());
|
||||
objectAccessException.add("field", stringBuffer.toString());
|
||||
throw objectAccessException;
|
||||
}
|
||||
try {
|
||||
long fieldOffset = getFieldOffset(field);
|
||||
Class<?> type = field.getType();
|
||||
if (!type.isPrimitive()) {
|
||||
SunLimitedUnsafeReflectionProvider.unsafe.putObject(obj, fieldOffset, obj2);
|
||||
return;
|
||||
}
|
||||
if (type.equals(Integer.TYPE)) {
|
||||
SunLimitedUnsafeReflectionProvider.unsafe.putInt(obj, fieldOffset, ((Integer) obj2).intValue());
|
||||
return;
|
||||
}
|
||||
if (type.equals(Long.TYPE)) {
|
||||
SunLimitedUnsafeReflectionProvider.unsafe.putLong(obj, fieldOffset, ((Long) obj2).longValue());
|
||||
return;
|
||||
}
|
||||
if (type.equals(Short.TYPE)) {
|
||||
SunLimitedUnsafeReflectionProvider.unsafe.putShort(obj, fieldOffset, ((Short) obj2).shortValue());
|
||||
return;
|
||||
}
|
||||
if (type.equals(Character.TYPE)) {
|
||||
SunLimitedUnsafeReflectionProvider.unsafe.putChar(obj, fieldOffset, ((Character) obj2).charValue());
|
||||
return;
|
||||
}
|
||||
if (type.equals(Byte.TYPE)) {
|
||||
SunLimitedUnsafeReflectionProvider.unsafe.putByte(obj, fieldOffset, ((Byte) obj2).byteValue());
|
||||
return;
|
||||
}
|
||||
if (type.equals(Float.TYPE)) {
|
||||
SunLimitedUnsafeReflectionProvider.unsafe.putFloat(obj, fieldOffset, ((Float) obj2).floatValue());
|
||||
return;
|
||||
}
|
||||
if (type.equals(Double.TYPE)) {
|
||||
SunLimitedUnsafeReflectionProvider.unsafe.putDouble(obj, fieldOffset, ((Double) obj2).doubleValue());
|
||||
return;
|
||||
}
|
||||
if (type.equals(Boolean.TYPE)) {
|
||||
SunLimitedUnsafeReflectionProvider.unsafe.putBoolean(obj, fieldOffset, ((Boolean) obj2).booleanValue());
|
||||
return;
|
||||
}
|
||||
ObjectAccessException objectAccessException2 = new ObjectAccessException("Cannot set field of unknown type", SunLimitedUnsafeReflectionProvider.exception);
|
||||
StringBuffer stringBuffer2 = new StringBuffer();
|
||||
stringBuffer2.append(obj.getClass());
|
||||
stringBuffer2.append(".");
|
||||
stringBuffer2.append(field.getName());
|
||||
objectAccessException2.add("field", stringBuffer2.toString());
|
||||
objectAccessException2.add("unknown-type", type.getName());
|
||||
throw objectAccessException2;
|
||||
} catch (IllegalArgumentException e) {
|
||||
ObjectAccessException objectAccessException3 = new ObjectAccessException("Cannot set field", e);
|
||||
StringBuffer stringBuffer3 = new StringBuffer();
|
||||
stringBuffer3.append(obj.getClass());
|
||||
stringBuffer3.append(".");
|
||||
stringBuffer3.append(field.getName());
|
||||
objectAccessException3.add("field", stringBuffer3.toString());
|
||||
throw objectAccessException3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider
|
||||
protected void init() {
|
||||
super.init();
|
||||
this.fieldOffsetCache = new WeakHashMap();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider, com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public void writeField(Object obj, String str, Object obj2, Class cls) {
|
||||
write(this.fieldDictionary.field(obj.getClass(), str, cls), obj, obj2);
|
||||
}
|
||||
|
||||
public SunUnsafeReflectionProvider(FieldDictionary fieldDictionary) {
|
||||
super(fieldDictionary);
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.thoughtworks.xstream.converters.reflection;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XStream12FieldKeySorter implements FieldKeySorter {
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.FieldKeySorter
|
||||
public Map sort(Class cls, Map map) {
|
||||
TreeMap treeMap = new TreeMap(new Comparator() { // from class: com.thoughtworks.xstream.converters.reflection.XStream12FieldKeySorter.1
|
||||
@Override // java.util.Comparator
|
||||
public int compare(Object obj, Object obj2) {
|
||||
FieldKey fieldKey = (FieldKey) obj;
|
||||
FieldKey fieldKey2 = (FieldKey) obj2;
|
||||
int depth = fieldKey2.getDepth() - fieldKey.getDepth();
|
||||
return depth == 0 ? fieldKey.getOrder() - fieldKey2.getOrder() : depth;
|
||||
}
|
||||
});
|
||||
treeMap.putAll(map);
|
||||
map.clear();
|
||||
map.putAll(treeMap);
|
||||
return map;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user