Skip to content

Commit

Permalink
Make Java runfiles library compilable with JDK 8
Browse files Browse the repository at this point in the history
The `FileReader(String,Charset)` constructor is not available in Java 8.

Fixes #16849
Work towards #16124

Closes #16851.

PiperOrigin-RevId: 491310720
Change-Id: I26f7bce346038d10285b0a1ee7b29216ba151010
  • Loading branch information
fmeum authored and copybara-github committed Nov 28, 2022
1 parent 3b4e5ec commit 0bc0ff5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/java/runfiles/Runfiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.ref.SoftReference;
Expand Down Expand Up @@ -410,7 +409,9 @@ private static Map<Preloaded.RepoMappingKey, String> loadRepositoryMapping(Strin
return Collections.emptyMap();
}

try (BufferedReader r = new BufferedReader(new FileReader(path, StandardCharsets.UTF_8))) {
try (BufferedReader r =
new BufferedReader(
new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8))) {
return Collections.unmodifiableMap(
r.lines()
.filter(line -> !line.isEmpty())
Expand Down

0 comments on commit 0bc0ff5

Please sign in to comment.