# HG changeset patch # User bpb # Date 1495137199 25200 # Node ID 06dcb7564c86523fa5e0e0798916a0690dcc31d7 # Parent 3df509b41e518e46c359d782b691d6974b8a3ea0 8177809: File.lastModified() is losing milliseconds (always ends in 000) Summary: Use higher precision time values where available. Reviewed-by: bchristi, rriggs diff -r 3df509b41e51 -r 06dcb7564c86 src/solaris/native/java/io/UnixFileSystem_md.c --- a/src/solaris/native/java/io/UnixFileSystem_md.c Fri Apr 23 01:47:38 2021 +0100 +++ b/src/solaris/native/java/io/UnixFileSystem_md.c Thu May 18 12:53:19 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -208,7 +208,13 @@ WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { struct stat64 sb; if (stat64(path, &sb) == 0) { - rv = 1000 * (jlong)sb.st_mtime; +#ifndef MACOSX + rv = (jlong)sb.st_mtim.tv_sec * 1000; + rv += (jlong)sb.st_mtim.tv_nsec / 1000000; +#else + rv = (jlong)sb.st_mtimespec.tv_sec * 1000; + rv += (jlong)sb.st_mtimespec.tv_nsec / 1000000; +#endif } } END_PLATFORM_STRING(env, path); return rv; @@ -392,8 +398,13 @@ struct timeval tv[2]; /* Preserve access time */ - tv[0].tv_sec = sb.st_atime; - tv[0].tv_usec = 0; +#ifndef MACOSX + tv[0].tv_sec = sb.st_atim.tv_sec; + tv[0].tv_usec = sb.st_atim.tv_nsec / 1000; +#else + tv[0].tv_sec = sb.st_atimespec.tv_sec; + tv[0].tv_usec = sb.st_atimespec.tv_nsec / 1000; +#endif /* Change last-modified time */ tv[1].tv_sec = time / 1000; diff -r 3df509b41e51 -r 06dcb7564c86 test/java/io/File/SetLastModified.java --- a/test/java/io/File/SetLastModified.java Fri Apr 23 01:47:38 2021 +0100 +++ b/test/java/io/File/SetLastModified.java Thu May 18 12:53:19 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - @bug 4091757 6652379 + @bug 4091757 6652379 8177809 @summary Basic test for setLastModified method */