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

(fs) BasicFileAttributeView.setTimes should support setting file create time on OS X

    XMLWordPrintable

Details

    • b10
    • generic
    • os_x

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_74"
      Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
      Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS 10.10.5

      A DESCRIPTION OF THE PROBLEM :
      when setting the creation time of a file via BasicFileAttributeView.setTimes only last modified and last accessed timestamps are modified, created remains unchanged.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      execute sample code and check file timestamps in OSX Finder or using command line tools.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The file creation, last modified and last accessed time should be set to the time when the code snippet below was executed.
      ACTUAL -
      Only last modified and last accessed are changed. Created remains unchanged. It is easy to check by looking at the file in Finder.

      When setting the file creation time by using a native Cocoa method (NSFileManager:setAttributes:ofItemAtPath:error:) mapped to Java, file creation time changes as expected.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      BasicFileAttributeView attributes = Files.getFileAttributeView(Paths.get(someFilePath), BasicFileAttributeView.class);
      FileTime time = FileTime.fromMillis(System.currentTimeMillis());
      attributes.setTimes(time, time, time);

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

      CUSTOMER SUBMITTED WORKAROUND :
      Use native calls (NSFileManager:setAttributes:ofItemAtPath:error:)

      Attachments

        Issue Links

          Activity

            People

              bpb Brian Burkhalter
              webbuggrp Webbug Group
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: