Change .kotlin_class_names format a little

Before writing a list of indexes of built-in classes' names, write the length
of such a list. It helps to read this list normally (not until an exception
happens)
This commit is contained in:
Alexander Udalov
2013-07-15 21:45:57 +04:00
parent d49a2ed613
commit 047ed18901
3 changed files with 34 additions and 20 deletions
Binary file not shown.
@@ -85,22 +85,25 @@ class BuiltinsNamespaceDescriptorImpl extends AbstractNamespaceDescriptorImpl {
private final NotNullLazyValue<Collection<Name>> classNames = storageManager.createLazyValue(new Computable<Collection<Name>>() {
@Override
public Collection<Name> compute() {
InputStream namesStream =
getStream(BuiltInsSerializationUtil.getClassNamesFilePath(BuiltinsNamespaceDescriptorImpl.this));
List<Name> result = new ArrayList<Name>();
InputStream in = getStream(BuiltInsSerializationUtil.getClassNamesFilePath(BuiltinsNamespaceDescriptorImpl.this));
try {
DataInputStream data = new DataInputStream(namesStream);
while (true) {
result.add(nameResolver.getName(data.readInt()));
DataInputStream data = new DataInputStream(in);
try {
int size = data.readInt();
List<Name> result = new ArrayList<Name>(size);
for (int i = 0; i < size; i++) {
result.add(nameResolver.getName(data.readInt()));
}
return result;
}
finally {
data.close();
}
}
catch (EOFException e) {
// OK: finishing the loop
}
catch (IOException e) {
throw new IllegalStateException(e);
}
return result;
}
});