Do not use Paths.get on ZipEntry names.

Paths.get uses the system encoding to encode all strings. Therefore,
if the system encoding is not UTF-8 we get in trouble.

R=sgjesse@google.com, zerny@google.com

Bug: 109992855
Change-Id: Ie460f08e1c2862f43eef97dc7a80313a73ae079f
diff --git a/src/test/apiUsageSample/com/android/tools/apiusagesample/D8ApiUsageSample.java b/src/test/apiUsageSample/com/android/tools/apiusagesample/D8ApiUsageSample.java
index 2ef0123..23dc7e0 100644
--- a/src/test/apiUsageSample/com/android/tools/apiusagesample/D8ApiUsageSample.java
+++ b/src/test/apiUsageSample/com/android/tools/apiusagesample/D8ApiUsageSample.java
@@ -391,8 +391,9 @@
         ZipInputStream zip = new ZipInputStream(Files.newInputStream(file), StandardCharsets.UTF_8);
         ZipEntry entry;
         while (null != (entry = zip.getNextEntry())) {
-          if (isClassFile(Paths.get(entry.getName()))) {
-            Origin origin = new ArchiveEntryOrigin(entry.getName(), zipOrigin);
+          String name = entry.getName();
+          if (isClassFile(name)) {
+            Origin origin = new ArchiveEntryOrigin(name, zipOrigin);
             classfiles.add(new ClassFileContent(origin, readBytes(zip)));
           }
         }
diff --git a/src/test/apiUsageSample/com/android/tools/apiusagesample/R8ApiUsageSample.java b/src/test/apiUsageSample/com/android/tools/apiusagesample/R8ApiUsageSample.java
index 2c2e8d7..7bce10a 100644
--- a/src/test/apiUsageSample/com/android/tools/apiusagesample/R8ApiUsageSample.java
+++ b/src/test/apiUsageSample/com/android/tools/apiusagesample/R8ApiUsageSample.java
@@ -382,8 +382,9 @@
         ZipInputStream zip = new ZipInputStream(Files.newInputStream(file), StandardCharsets.UTF_8);
         ZipEntry entry;
         while (null != (entry = zip.getNextEntry())) {
-          if (isClassFile(Paths.get(entry.getName()))) {
-            Origin origin = new ArchiveEntryOrigin(entry.getName(), zipOrigin);
+          String name = entry.getName();
+          if (isClassFile(name)) {
+            Origin origin = new ArchiveEntryOrigin(name, zipOrigin);
             classfiles.add(new ClassFileContent(origin, readBytes(zip)));
           }
         }
diff --git a/src/test/java/com/android/tools/r8/ArchiveClassFileProviderTest.java b/src/test/java/com/android/tools/r8/ArchiveClassFileProviderTest.java
new file mode 100644
index 0000000..6ceb0a2
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/ArchiveClassFileProviderTest.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2018 the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+public class ArchiveClassFileProviderTest {
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  public Path createZip() throws IOException {
+    Path tempRoot = temporaryFolder.getRoot().toPath();
+    Path zipFile = tempRoot.resolve("zipfile.zip");
+    ZipOutputStream zipStream =
+        new ZipOutputStream(new FileOutputStream(zipFile.toFile()), StandardCharsets.UTF_8);
+    ZipEntry entry = new ZipEntry("non-ascii:$\u02CF");
+    zipStream.putNextEntry(entry);
+    zipStream.write(10);
+    zipStream.close();
+    return zipFile;
+  }
+
+  @Test
+  public void testSystemLocale() throws IOException, ResourceException {
+    // Set the locale used for Paths to ASCII which will make Path creation fail
+    // for non-ascii names.
+    System.setProperty("sun.jnu.encoding", "ASCII");
+    Path zipFile = createZip();
+    new ArchiveClassFileProvider(zipFile);
+    ArchiveProgramResourceProvider.fromArchive(zipFile).getProgramResources();
+  }
+}