99 lines
3.5 KiB
Java
99 lines
3.5 KiB
Java
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);
|
|
}
|
|
}
|