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

jar does not preserve file modification times during extract

    Details

    • Subcomponent:
      jar
    • Resolved In Build:
      b83
    • CPU:
      generic, x86, sparc
    • OS:
      generic, solaris_8, solaris_10, windows_2000

      Description

      Name: krT82822 Date: 03/30/99


      The jar tool does not preserve the creation/modification date
      of any archived files on Windows 95.
      Extracted files always get the date of the extraction event.

      This is data loss.

      Inside the jar file, (viewed with Winzip), the dates seem to be
      correct.
      (Review ID: 56275)
      ======================================================================
      Suggested fix provided by https://mustang.dev.java.net/ member dmytro_sheyko:

      A DESCRIPTION OF THE FIX :
        Bug number : 4225317
        Bug Description : jar does not preserve file modification dates during extract (win95)
      Diff Baseline : Mustang b65.
      Diff :
      --- j2se/src/share/classes/sun/tools/jar/Main.java.prev Thu Jan 05 10:41:00 2006
      +++ j2se/src/share/classes/sun/tools/jar/Main.java Thu Jan 05 10:41:09 2006
      @@ -753,39 +753,43 @@
           /*
            * Extracts next entry from JAR file, creating directories as needed.
            */
           void extractFile(ZipInputStream zis, ZipEntry e) throws IOException {
               String name = e.getName();
        File f = new File(e.getName().replace('/', File.separatorChar));
        if (e.isDirectory()) {
        if (!f.exists() && !f.mkdirs() || !f.isDirectory()) {
        throw new IOException(formatMsg("error.create.dir",
        f.getPath()));
        }
        if (vflag) {
         output(formatMsg("out.create", name));
        }
        } else {
        if (f.getParent() != null) {
        File d = new File(f.getParent());
        if (!d.exists() && !d.mkdirs() || !d.isDirectory()) {
        throw new IOException(formatMsg(
        "error.create.dir", d.getPath()));
        }
        }
        OutputStream os = new FileOutputStream(f);
        byte[] b = new byte[512];
        int len;
        while ((len = zis.read(b, 0, b.length)) != -1) {
        os.write(b, 0, len);
        }
        zis.closeEntry();
        os.close();
        if (vflag) {
        if (e.getMethod() == ZipEntry.DEFLATED) {
                           output(formatMsg("out.inflated", name));
        } else {
                           output(formatMsg("out.extracted", name));
        }
        }
        }
      + long lastModified = e.getTime();
      + if(lastModified != -1) {
      + f.setLastModified(lastModified);
      + }
           }


      FIX FOR BUG NUMBER:
      4225317

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bristor Dave Bristor
                Reporter:
                kryansunw Kevin Ryan (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: