readAvailable(input, resources);
log.info("Fakereplace is checking for updates classes. Client sent " + classes.size() + "classes");
final ChangedClasses classesToReplace = CurrentEnvironment.getEnvironment().getUpdatedClasses(archiveName, classes);
final Map<String, Class> classMap = new HashMap<String, Class>();
output.writeInt(classesToReplace.getChanged().size() + classesToReplace.getNewClasses().size());
for (Class clazz : classesToReplace.getChanged()) {
final String cname = clazz.getName();
output.writeInt(cname.length());
output.write(cname.getBytes());
classMap.put(cname, clazz);
}
for (String cname : classesToReplace.getNewClasses()) {
output.writeInt(cname.length());
output.write(cname.getBytes());
}
final Set<String> resourcesToReplace = CurrentEnvironment.getEnvironment().getUpdatedResources(archiveName, resources);
output.writeInt(resourcesToReplace.size());
for (String cname : resourcesToReplace) {
output.writeInt(cname.length());
output.write(cname.getBytes());
}
output.flush();
final Set<ClassDefinition> classDefinitions = new HashSet<ClassDefinition>();
final Set<Class<?>> replacedClasses = new HashSet<Class<?>>();
final List<AddedClass> addedClassList = new ArrayList<AddedClass>();
int noClasses = input.readInt();
for (int i = 0; i < noClasses; ++i) {
final String className = readString(input);
int length = input.readInt();
byte[] buffer = new byte[length];
for (int j = 0; j < length; ++j) {
buffer[j] = (byte) input.read();
}
final Class theClass = classMap.get(className);
if (theClass != null) {
classDefinitions.add(new ClassDefinition(theClass, buffer));
replacedClasses.add(theClass);
} else {
addedClassList.add(new AddedClass(className, buffer, classesToReplace.getClassLoader()));
}
}
final Map<String, byte[]> replacedResources = new HashMap<String, byte[]>();