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 ----------