}
ClassDescriptor superDescriptor = doReadClassDescriptor(readUnsignedByte());
if (superDescriptor != null) {
final Class<?> superType = superDescriptor.getType();
if (! superType.isAssignableFrom(clazz)) {
throw new InvalidClassException(clazz.getName(), "Class does not extend stream superclass");
}
Class<?> cl = superClazz;
while (cl != superType) {
superDescriptor = new SerializableGapClassDescriptor(registry.lookup(cl), superDescriptor);
cl = cl.getSuperclass();
}
} else if (superClazz != null) {
Class<?> cl = superClazz;
while (serializabilityChecker.isSerializable(cl)) {
superDescriptor = new SerializableGapClassDescriptor(registry.lookup(cl), superDescriptor);
cl = cl.getSuperclass();
}
}
final SerializableClass serializableClass = registry.lookup(clazz);
final SerializableField[] fields = new SerializableField[cnt];
for (int i = 0; i < cnt; i ++) {
fields[i] = serializableClass.getSerializableField(names[i], descriptors[i].getType(), unshareds[i]);
}
descriptor.setResult(new BasicSerializableClassDescriptor(serializableClass, superDescriptor, fields, classType));
return descriptor;
}
case ID_EXTERNALIZABLE_CLASS: {
final String className = readString();
final long uid = readLong();
final Class<?> clazz = classResolver.resolveClass(this, className, uid);
final SimpleClassDescriptor descriptor = new SimpleClassDescriptor(clazz, ID_EXTERNALIZABLE_CLASS);
classCache.add(descriptor);
return descriptor;
}
case ID_EXTERNALIZER_CLASS: {
final String className = readString();
int idx = classCache.size();
classCache.add(null);
final Class<?> clazz = classResolver.resolveClass(this, className, 0L);
final Externalizer externalizer = (Externalizer) readObject();
final SimpleClassDescriptor descriptor = new ExternalizerClassDescriptor(clazz, externalizer);
classCache.set(idx, descriptor);
return descriptor;
}
case ID_ENUM_TYPE_CLASS: {
final SimpleClassDescriptor descriptor = new SimpleClassDescriptor(classResolver.resolveClass(this, readString(), 0L), ID_ENUM_TYPE_CLASS);
classCache.add(descriptor);
return descriptor;
}
case ID_OBJECT_ARRAY_TYPE_CLASS: {
final ClassDescriptor elementType = doReadClassDescriptor(readUnsignedByte());
final SimpleClassDescriptor arrayDescriptor = new SimpleClassDescriptor(Array.newInstance(elementType.getType(), 0).getClass(), ID_OBJECT_ARRAY_TYPE_CLASS);
classCache.add(arrayDescriptor);
return arrayDescriptor;
}
case ID_CC_ARRAY_LIST: {
return ClassDescriptors.CC_ARRAY_LIST;
}
case ID_CC_LINKED_LIST: {
return ClassDescriptors.CC_LINKED_LIST;
}
case ID_CC_HASH_SET: {
return ClassDescriptors.CC_HASH_SET;
}
case ID_CC_LINKED_HASH_SET: {
return ClassDescriptors.CC_LINKED_HASH_SET;
}
case ID_CC_TREE_SET: {
return ClassDescriptors.CC_TREE_SET;
}
case ID_CC_IDENTITY_HASH_MAP: {
return ClassDescriptors.CC_IDENTITY_HASH_MAP;
}
case ID_CC_HASH_MAP: {
return ClassDescriptors.CC_HASH_MAP;
}
case ID_CC_HASHTABLE: {
return ClassDescriptors.CC_HASHTABLE;
}
case ID_CC_LINKED_HASH_MAP: {
return ClassDescriptors.CC_LINKED_HASH_MAP;
}
case ID_CC_TREE_MAP: {
return ClassDescriptors.CC_TREE_MAP;
}
case ID_CC_ENUM_SET: {
return ClassDescriptors.CC_ENUM_SET;
}
case ID_CC_ENUM_MAP: {
return ClassDescriptors.CC_ENUM_MAP;
}
case ID_ABSTRACT_COLLECTION: {
return ClassDescriptors.ABSTRACT_COLLECTION;
}
case ID_ABSTRACT_LIST: {
return ClassDescriptors.ABSTRACT_LIST;
}
case ID_ABSTRACT_QUEUE: {
return ClassDescriptors.ABSTRACT_QUEUE;
}
case ID_ABSTRACT_SEQUENTIAL_LIST: {
return ClassDescriptors.ABSTRACT_SEQUENTIAL_LIST;
}
case ID_ABSTRACT_SET: {
return ClassDescriptors.ABSTRACT_SET;
}
case ID_CC_CONCURRENT_HASH_MAP: {
return ClassDescriptors.CONCURRENT_HASH_MAP;
}
case ID_CC_COPY_ON_WRITE_ARRAY_LIST: {
return ClassDescriptors.COPY_ON_WRITE_ARRAY_LIST;
}
case ID_CC_COPY_ON_WRITE_ARRAY_SET: {
return ClassDescriptors.COPY_ON_WRITE_ARRAY_SET;
}
case ID_CC_VECTOR: {
return ClassDescriptors.VECTOR;
}
case ID_CC_STACK: {
return ClassDescriptors.STACK;
}
case ID_CC_ARRAY_DEQUE: {
return ClassDescriptors.ARRAY_DEQUE;
}
case ID_CC_NCOPIES: {
return ClassDescriptors.NCOPIES;
}
case ID_SINGLETON_MAP_OBJECT: {
return ClassDescriptors.SINGLETON_MAP;
}
case ID_SINGLETON_SET_OBJECT: {
return ClassDescriptors.SINGLETON_SET;
}
case ID_SINGLETON_LIST_OBJECT: {
return ClassDescriptors.SINGLETON_LIST;
}
case ID_EMPTY_MAP_OBJECT: {
return ClassDescriptors.EMPTY_MAP;
}
case ID_EMPTY_SET_OBJECT: {
return ClassDescriptors.EMPTY_SET;
}
case ID_EMPTY_LIST_OBJECT: {
return ClassDescriptors.EMPTY_LIST;
}
case ID_REVERSE_ORDER_OBJECT: {
return ClassDescriptors.REVERSE_ORDER;
}
case ID_REVERSE_ORDER2_OBJECT: {
return ClassDescriptors.REVERSE_ORDER2;
}
case ID_PAIR: {
return ClassDescriptors.PAIR;
}
case ID_STRING_CLASS: {
return ClassDescriptors.STRING_DESCRIPTOR;
}
case ID_OBJECT_CLASS: {
return ClassDescriptors.OBJECT_DESCRIPTOR;
}
case ID_CLASS_CLASS: {
return ClassDescriptors.CLASS_DESCRIPTOR;
}
case ID_ENUM_CLASS: {
return ClassDescriptors.ENUM_DESCRIPTOR;
}
case ID_BOOLEAN_ARRAY_CLASS: {
return ClassDescriptors.BOOLEAN_ARRAY;
}
case ID_BYTE_ARRAY_CLASS: {
return ClassDescriptors.BYTE_ARRAY;
}
case ID_SHORT_ARRAY_CLASS: {
return ClassDescriptors.SHORT_ARRAY;
}
case ID_INT_ARRAY_CLASS: {
return ClassDescriptors.INT_ARRAY;
}
case ID_LONG_ARRAY_CLASS: {
return ClassDescriptors.LONG_ARRAY;
}
case ID_CHAR_ARRAY_CLASS: {
return ClassDescriptors.CHAR_ARRAY;
}
case ID_FLOAT_ARRAY_CLASS: {
return ClassDescriptors.FLOAT_ARRAY;
}
case ID_DOUBLE_ARRAY_CLASS: {
return ClassDescriptors.DOUBLE_ARRAY;
}
case ID_PRIM_BOOLEAN: {
return ClassDescriptors.BOOLEAN;
}
case ID_PRIM_BYTE: {
return ClassDescriptors.BYTE;
}
case ID_PRIM_CHAR: {
return ClassDescriptors.CHAR;
}
case ID_PRIM_DOUBLE: {
return ClassDescriptors.DOUBLE;
}
case ID_PRIM_FLOAT: {
return ClassDescriptors.FLOAT;
}
case ID_PRIM_INT: {
return ClassDescriptors.INT;
}
case ID_PRIM_LONG: {
return ClassDescriptors.LONG;
}
case ID_PRIM_SHORT: {
return ClassDescriptors.SHORT;
}
case ID_VOID: {
return ClassDescriptors.VOID;
}
case ID_BOOLEAN_CLASS: {
return ClassDescriptors.BOOLEAN_OBJ;
}
case ID_BYTE_CLASS: {
return ClassDescriptors.BYTE_OBJ;
}
case ID_SHORT_CLASS: {
return ClassDescriptors.SHORT_OBJ;
}
case ID_INTEGER_CLASS: {
return ClassDescriptors.INTEGER_OBJ;
}
case ID_LONG_CLASS: {
return ClassDescriptors.LONG_OBJ;
}
case ID_CHARACTER_CLASS: {
return ClassDescriptors.CHARACTER_OBJ;
}
case ID_FLOAT_CLASS: {
return ClassDescriptors.FLOAT_OBJ;
}
case ID_DOUBLE_CLASS: {
return ClassDescriptors.DOUBLE_OBJ;
}
case ID_VOID_CLASS: {
return ClassDescriptors.VOID_OBJ;
}
default: {
throw new InvalidClassException("Unexpected class ID " + classType);
}
}
}