Skip to content

Commit 8076a56

Browse files
committed
Address Gilles' review comment.
1 parent d2a5c53 commit 8076a56

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/NativeLibraries.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package com.oracle.svm.hosted.c;
2626

27+
import java.io.BufferedReader;
2728
import java.io.IOException;
2829
import java.nio.file.Files;
2930
import java.nio.file.Path;
@@ -33,7 +34,6 @@
3334
import java.util.Collection;
3435
import java.util.Collections;
3536
import java.util.HashMap;
36-
import java.util.Iterator;
3737
import java.util.LinkedHashMap;
3838
import java.util.LinkedHashSet;
3939
import java.util.LinkedList;
@@ -628,12 +628,11 @@ private static StaticLibraryManifest readStaticLibraryManifest(Path libraryPath)
628628
if (!Files.isRegularFile(symbolsPath)) {
629629
return new StaticLibraryManifest(List.of(), List.of());
630630
}
631-
try {
631+
try (BufferedReader reader = Files.newBufferedReader(symbolsPath)) {
632632
List<String> symbols = new ArrayList<>();
633633
List<String> dependencies = new ArrayList<>();
634-
Iterator<String> lines = Files.readAllLines(symbolsPath).iterator();
635-
while (lines.hasNext()) {
636-
String line = lines.next();
634+
String line;
635+
while ((line = reader.readLine()) != null) {
637636
VMError.guarantee(!line.isBlank(), "Malformed static library manifest: empty line in %s", symbolsPath);
638637
if (!line.startsWith(STATIC_LIBRARY_DEPENDENCY_PREFIX)) {
639638
symbols.add(line);
@@ -643,8 +642,7 @@ private static StaticLibraryManifest readStaticLibraryManifest(Path libraryPath)
643642
VMError.guarantee(!dependency.isEmpty(), "Malformed static library manifest: %s", symbolsPath);
644643
dependencies.add(dependency);
645644
}
646-
while (lines.hasNext()) {
647-
String line = lines.next();
645+
while ((line = reader.readLine()) != null) {
648646
VMError.guarantee(!line.isBlank(), "Malformed static library manifest: empty line in %s", symbolsPath);
649647
VMError.guarantee(!line.startsWith(STATIC_LIBRARY_DEPENDENCY_PREFIX), "Malformed static library manifest: dependency after symbol in %s", symbolsPath);
650648
symbols.add(line);

0 commit comments

Comments
 (0)