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

(spec) File.setLastModified(long) makes assumption on precision that isn't feasible everywhere

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • tbd
    • 1.4.0
    • core-libs
    • x86
    • windows_2000

      Name: nt126004 Date: 06/05/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      On some computers (all running the same JDK and same version
      of Windows), File.setLastModified sets the time to the
      specified time rounded up to the nearest even second.

      Also on these computers setting times below a certain number
      doesn't work either (method returns false).

      The spec says All platforms support file-modification times
      to the nearest second, but some provide more precision. The
      argument will be truncated to fit the supported precision.

      Upto 2 seconds up is not to the nearest second.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Find a particular machine that has this problem (has been
      seen on some Windows 2000 and Windows 98 machines, but other
      Windows 2000 machines have allowed times correct to the
      millisecond)
      2. create a test file (c:/temp/test.txt)
      3. run the code


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected: both tests to succeed and for the times displayed
      to be within half a second of the last modified times displayed.

      Actual: 1st test is out by almost 2 seconds, 2nd test
      returns false

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;

      public class Test {
        public static void main(String[] args) {
          File f = new File("c:/temp/test.txt");
          System.out.println("Last Modified Time: " + f.lastModified());
          System.out.println("Setting Time to 1023199010001 succeeded: " +
      f.setLastModified(1023199010001L));
          System.out.println("Last Modified Time: " + f.lastModified());
          System.out.println("Setting Time to 1000 succeeded: " +
      f.setLastModified(1000));
          System.out.println("Last Modified Time: " + f.lastModified());
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      when comparing modified times allow for up to 4 seconds in
      differences and hope that no computers are further away from
      spec
      (Review ID: 148188)
      ======================================================================

            bpb Brian Burkhalter
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: