Retarget FileChannel#open inside desugared library

Change-Id: I8a7fdb0ebaca8566f3e95bb64790eaee0b6dfaae
diff --git a/src/library_desugar/jdk11/desugar_jdk_libs_nio.json b/src/library_desugar/jdk11/desugar_jdk_libs_nio.json
index dcd5329..244aa34 100644
--- a/src/library_desugar/jdk11/desugar_jdk_libs_nio.json
+++ b/src/library_desugar/jdk11/desugar_jdk_libs_nio.json
@@ -214,6 +214,9 @@
         "java.nio.file.ProviderNotFoundException",
         "java.nio.file.ReadOnlyFileSystemException"
       ],
+      "retarget_method": {
+        "java.nio.channels.FileChannel java.nio.channels.FileChannel#open(java.nio.file.Path, java.nio.file.OpenOption[])": "java.nio.channels.DesugarChannels"
+      },
       "retarget_method_with_emulated_dispatch": {
         "java.nio.file.Path java.io.File#toPath()": "java.io.DesugarFile"
       },
@@ -434,7 +437,6 @@
         "java.util.Date java.util.Date#from(java.time.Instant)": "java.util.DesugarDate",
         "java.util.GregorianCalendar java.util.GregorianCalendar#from(java.time.ZonedDateTime)": "java.util.DesugarGregorianCalendar",
         "java.util.TimeZone java.util.TimeZone#getTimeZone(java.lang.String)": "java.util.DesugarTimeZone",
-        "java.nio.channels.FileChannel java.nio.channels.FileChannel#open(java.nio.file.Path, java.nio.file.OpenOption[])": "java.nio.channels.DesugarChannels",
         "java.nio.channels.FileChannel java.nio.channels.FileChannel#open(java.nio.file.Path, java.util.Set, java.nio.file.attribute.FileAttribute[])": "java.nio.channels.DesugarChannels"
       }
     },
diff --git a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/jdk11/FilesTest.java b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/jdk11/FilesTest.java
index fb9ca6a..6557982 100644
--- a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/jdk11/FilesTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/jdk11/FilesTest.java
@@ -18,6 +18,7 @@
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.channels.SeekableByteChannel;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.LinkOption;
@@ -35,6 +36,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Stream;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -43,51 +45,44 @@
 @RunWith(Parameterized.class)
 public class FilesTest extends DesugaredLibraryTestBase {
 
+  private static final String END_EXPECTED_RESULT =
+      StringUtils.lines("j$.nio.file.attribute", "tmp", "/", "true", "This", "is", "fun!");
   private static final String EXPECTED_RESULT_DESUGARING_FILE_SYSTEM =
       StringUtils.lines(
-          "bytes written: 11",
-          "String written: Hello World",
-          "bytes read: 11",
-          "String read: Hello World",
-          "bytes read: 11",
-          "String read: Hello World",
-          "null",
-          "true",
-          "unsupported",
-          "j$.nio.file.attribute",
-          "tmp",
-          "/",
-          "true");
+              "bytes written: 11",
+              "String written: Hello World",
+              "bytes read: 11",
+              "String read: Hello World",
+              "bytes read: 11",
+              "String read: Hello World",
+              "null",
+              "true",
+              "unsupported")
+          + END_EXPECTED_RESULT;
   private static final String EXPECTED_RESULT_PLATFORM_FILE_SYSTEM_DESUGARING =
       StringUtils.lines(
-          "bytes written: 11",
-          "String written: Hello World",
-          "bytes read: 11",
-          "String read: Hello World",
-          "bytes read: 11",
-          "String read: Hello World",
-          "true",
-          "true",
-          "true",
-          "j$.nio.file.attribute",
-          "tmp",
-          "/",
-          "true");
+              "bytes written: 11",
+              "String written: Hello World",
+              "bytes read: 11",
+              "String read: Hello World",
+              "bytes read: 11",
+              "String read: Hello World",
+              "true",
+              "true",
+              "true")
+          + END_EXPECTED_RESULT;
   private static final String EXPECTED_RESULT_PLATFORM_FILE_SYSTEM =
       StringUtils.lines(
-          "bytes written: 11",
-          "String written: Hello World",
-          "bytes read: 11",
-          "String read: Hello World",
-          "bytes read: 11",
-          "String read: Hello World",
-          "true",
-          "true",
-          "true",
-          "java.nio.file.attribute",
-          "tmp",
-          "/",
-          "true");
+              "bytes written: 11",
+              "String written: Hello World",
+              "bytes read: 11",
+              "String read: Hello World",
+              "bytes read: 11",
+              "String read: Hello World",
+              "true",
+              "true",
+              "true")
+          + END_EXPECTED_RESULT;
 
   private final TestParameters parameters;
   private final LibraryDesugaringSpecification libraryDesugaringSpecification;
@@ -145,6 +140,7 @@
       Files.setAttribute(path, "basic:lastModifiedTime", FileTime.from(Instant.EPOCH));
       fspMethodsWithGeneric(path);
       pathGeneric();
+      lines(path);
     }
 
     private static void pathGeneric() throws IOException {
@@ -192,6 +188,12 @@
       }
     }
 
+    private static void lines(Path path) throws IOException {
+      Files.write(path, "This\nis\nfun!".getBytes(StandardCharsets.UTF_8));
+      Stream<String> lines = Files.lines(path, StandardCharsets.UTF_8);
+      lines.forEach(System.out::println);
+    }
+
     private static void readWriteThroughFilesAPI(Path path) throws IOException {
       try (SeekableByteChannel channel =
           Files.newByteChannel(path, StandardOpenOption.READ, StandardOpenOption.WRITE)) {