return;
}
output.writeVarInt(object.length + 1, true);
Class elementClass = object.getClass().getComponentType();
if (elementsAreSameType || Modifier.isFinal(elementClass.getModifiers())) {
Serializer elementSerializer = kryo.getSerializer(elementClass);
// if(generics!=null)
elementSerializer.setGenerics(kryo, generics);
for (int i = 0, n = object.length; i < n; i++) {
if (elementsCanBeNull)
kryo.writeObjectOrNull(output, object[i], elementSerializer);
else
kryo.writeObject(output, object[i], elementSerializer);
}
} else {
// Generics genericsScope = null;
// Class componentType = type;
// while(componentType.getComponentType() != null) {
// componentType = componentType.getComponentType();
// }
// TypeVariable[] typeVars = type.getComponentType().getTypeParameters();
// if(typeVars != null && generics != null) {
// if(TRACE) trace("kryo", "Creating a new GenericsScope for " + type.getName() + " with type vars: " + Arrays.toString(typeVars));
// genericsScope = new Generics();
// int i = 0;
// for(TypeVariable typeVar: typeVars) {
// genericsScope.add(typeVar.getName(), generics[i]);
// i++;
// }
// kryo.pushGenericsScope(type, genericsScope);
// }
//
for (int i = 0, n = object.length; i < n; i++) {
// Propagate generics?
if (object[i] != null) {
Serializer serializer = kryo.getSerializer(object[i].getClass());
serializer.setGenerics(kryo, generics);
}
kryo.writeClassAndObject(output, object[i]);
}
// if(genericsScope != null)