if (f.tag == tag) {
cachedField = f;
break;
}
}
if (cachedField == null) throw new KryoException("Unknown field tag: " + tag + " (" + getType().getName() + ")");
try {
if (TRACE) trace("kryo", "Read field: " + cachedField + " (" + getType().getName() + ")");
Object value;
Class concreteType = cachedField.valueClass;
Serializer serializer = cachedField.serializer;
if (concreteType == null) {
Registration registration = kryo.readClass(input);
if (registration == null)
value = null;
else {
if (serializer == null) serializer = registration.getSerializer();
if (cachedField.generics != null) serializer.setGenerics(kryo, cachedField.generics);
value = kryo.readObject(input, registration.getType(), serializer);
}
} else {
if (serializer == null) cachedField.serializer = serializer = kryo.getSerializer(concreteType);
if (cachedField.generics != null) serializer.setGenerics(kryo, cachedField.generics);
if (cachedField.canBeNull)
value = kryo.readObjectOrNull(input, concreteType, serializer);
else
value = kryo.readObject(input, concreteType, serializer);
}
cachedField.set(object, value);
} catch (IllegalAccessException ex) {
throw new KryoException("Error accessing field: " + cachedField + " (" + getType().getName() + ")", ex);
} catch (KryoException ex) {
ex.addTrace(cachedField + " (" + getType().getName() + ")");
throw ex;
} catch (RuntimeException runtimeEx) {
KryoException ex = new KryoException(runtimeEx);
ex.addTrace(cachedField + " (" + getType().getName() + ")");
throw ex;
}
}
return object;
}