Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8061777

(zipfs) IllegalArgumentException in ZipCoder.toString when using Shitft_JIS

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7u72, 8u25
    • Fix Version/s: 9
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b122
    • CPU:
      x86
    • OS:
      windows_7

      Backports

        Description

        FULL PRODUCT VERSION :
        1.7.0_72
        1.8.0_25

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows Version 6.1.7601

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Windows System Locale : Japanese

        A DESCRIPTION OF THE PROBLEM :
        I'm writing a zip utility program with reference to Java SE 7 Documentation.

        http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html

        IllegalArgumentException occurs when I try to convert some characters encoding into Shift_JIS.
        Some characters are "\u8868" (0x955c in Shift_JIS), "\u7533 " (0x905c in Shift_JIS), "\u80fd" (0x945c in Shift_JIS) and so on. All the characters have "0x5c".
        I have no problem without "0x5c" charcter.

        ----------
          FileSystem zipfs = FileSystems.newFileSystem(uri, env);
          zipfs.getPath(...);

          Exception in thread "main" java.lang.IllegalArgumentException: MALFORMED[1]
                at com.sun.nio.zipfs.ZipCoder.toString(ZipCoder.java:70)
        ----------

        The encoding of the source code is Shift_JIS, and I compile with "-encoding Shift_JIS" option.

        How may I convert this to Shift_JIS filename?


        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Exception in thread "main" java.lang.IllegalArgumentException: MALFORMED[1]
                at com.sun.nio.zipfs.ZipCoder.toString(ZipCoder.java:70)
                at com.sun.nio.zipfs.ZipCoder.toString(ZipCoder.java:78)
                at com.sun.nio.zipfs.ZipFileSystem.getString(ZipFileSystem.java:916)
                at com.sun.nio.zipfs.ZipFileSystem.deleteFile(ZipFileSystem.java:1342)
                at com.sun.nio.zipfs.ZipPath.delete(ZipPath.java:655)
                at com.sun.nio.zipfs.ZipFileSystemProvider.delete(ZipFileSystemProvider.java:206)
                at java.nio.file.spi.FileSystemProvider.deleteIfExists(Unknown Source)
                at java.nio.file.Files.deleteIfExists(Unknown Source)
                at java.nio.file.CopyMoveHelper.copyToForeignTarget(Unknown Source)
                at java.nio.file.Files.copy(Unknown Source)
                at ZipFSPUser.main(ZipFSPUser.java:20)

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public class ZipFSPUser {
          public static void main(String [] args) throws Throwable {
            Map<String, String> env = new HashMap<>();
            env.put("create", "true");
            env.put("encoding", "Shift_JIS");
            // locate file system by using the syntax
            // defined in java.net.JarURLConnection
            URI uri = URI.create("jar:file:/C:/codeSamples/zipfs/zipfstest.zip");

            try (FileSystem zipfs = FileSystems.newFileSystem(uri, env)) {
              Path externalTxtFile = Paths.get("C:\\表.txt");
              System.out.println(externalTxtFile);
              Path pathInZipfile = zipfs.getPath("/表.txt");
              // copy a file into the zip file
              Files.copy( externalTxtFile, pathInZipfile, StandardCopyOption.REPLACE_EXISTING );
            }
          }
        }

        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                sherman Xueming Shen
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: