From 0bc0ff5244142eb3348d42025ce21eeb337ad189 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Mon, 28 Nov 2022 04:46:07 -0800 Subject: [PATCH] Make Java runfiles library compilable with JDK 8 The `FileReader(String,Charset)` constructor is not available in Java 8. Fixes #16849 Work towards #16124 Closes #16851. PiperOrigin-RevId: 491310720 Change-Id: I26f7bce346038d10285b0a1ee7b29216ba151010 --- tools/java/runfiles/Runfiles.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/java/runfiles/Runfiles.java b/tools/java/runfiles/Runfiles.java index 171d1b2078ade4..c705e1db48bd94 100644 --- a/tools/java/runfiles/Runfiles.java +++ b/tools/java/runfiles/Runfiles.java @@ -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; @@ -410,7 +409,9 @@ private static Map 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())