-
Enhancement
-
Resolution: Fixed
-
P4
-
6u10
-
b175
-
x86
-
windows_xp
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8182826 | 10 | Brian Burkhalter | P4 | Resolved | Fixed | b14 |
JDK-8182528 | 9.0.4 | Brian Burkhalter | P4 | Resolved | Fixed | b01 |
A DESCRIPTION OF THE REQUEST :
File.lastModified() returns a negative value when the timestamp is before the epoch. However, File.setLastModified() does not allow negative timestamps --- the specs require that it throws an IllegalArgumentException if the argument is negative. This behavior is incompatible.
JUSTIFICATION :
Violates our assumption on how the pair of methods should work --- a valid return value from lastModified() should be a valid argument for setLastModified(). This poses problems when synchronizing files.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
setLastModified() should accept negative values.
ACTUAL -
setLastModified() throws an IllegalArgumentException if the argument is negative.
---------- BEGIN SOURCE ----------
/* create the file "test" with a last modified timestamp that is before the epoch (i.e. 1970), e.g. by using touch */
public static void main(String[] args)
{
File f = new File("test");
long time = f.lastModified();
f.setLastModified(time); /* throws an IllegalArgumentException */
}
---------- END SOURCE ----------
File.lastModified() returns a negative value when the timestamp is before the epoch. However, File.setLastModified() does not allow negative timestamps --- the specs require that it throws an IllegalArgumentException if the argument is negative. This behavior is incompatible.
JUSTIFICATION :
Violates our assumption on how the pair of methods should work --- a valid return value from lastModified() should be a valid argument for setLastModified(). This poses problems when synchronizing files.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
setLastModified() should accept negative values.
ACTUAL -
setLastModified() throws an IllegalArgumentException if the argument is negative.
---------- BEGIN SOURCE ----------
/* create the file "test" with a last modified timestamp that is before the epoch (i.e. 1970), e.g. by using touch */
public static void main(String[] args)
{
File f = new File("test");
long time = f.lastModified();
f.setLastModified(time); /* throws an IllegalArgumentException */
}
---------- END SOURCE ----------
- backported by
-
JDK-8182528 (file spec) Incompatible File.lastModified() and setLastModified() for negative time
-
- Resolved
-
-
JDK-8182826 (file spec) Incompatible File.lastModified() and setLastModified() for negative time
-
- Resolved
-
- duplicates
-
JDK-8180767 A return value of zero from java.io.File#lastModified() is ambiguous
-
- Closed
-
- relates to
-
JDK-7086489 File.lastModified should specify accuracy as well as resolution
-
- Closed
-
- links to
(3 links to)