test/tools/javac/diags/MessageFile.java
Print this page
@@ -63,11 +63,10 @@
insertAfter(l);
return l;
}
void insertAfter(Line l) {
- assert prev == null && next == null;
l.prev = this;
l.next = next;
if (next == null)
lastLine = l;
else
@@ -80,11 +79,10 @@
insertBefore(l);
return l;
}
void insertBefore(Line l) {
- assert prev == null && next == null;
l.prev = prev;
l.next = this;
if (prev == null)
firstLine = l;
else
@@ -408,15 +406,12 @@
Line firstLine;
Line lastLine;
Map<String, Message> messages = new TreeMap<String, Message>();
MessageFile(File file) throws IOException {
- Reader in = new FileReader(file);
- try {
+ try(Reader in = new FileReader(file)) {
read(in);
- } finally {
- in.close();
}
}
MessageFile(Reader in) throws IOException {
read(in);
@@ -440,15 +435,12 @@
}
}
}
void write(File file) throws IOException {
- Writer out = new FileWriter(file);
- try {
+ try(Writer out = new FileWriter(file)) {
write(out);
- } finally {
- out.close();
}
}
void write(Writer out) throws IOException {
BufferedWriter bw = (out instanceof BufferedWriter)