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:)
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:)
- duplicates
-
JDK-8165728 (fs) BasicFileAttributeView should support setting birth time (creationTime) on OS X/HFS
-
- Closed
-
- relates to
-
JDK-8337275 Files.setTimes and creationTime APIs inconsistent
-
- Closed
-