|
1 | 1 | /* |
2 | | - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -66,7 +66,9 @@ public class ReproducibleJar { |
66 | 66 | private static final TimeZone TZ = TimeZone.getDefault(); |
67 | 67 | private static final boolean DST = TZ.inDaylightTime(new Date()); |
68 | 68 | private static final String UNIX_2038_ROLLOVER_TIME = "2038-01-19T03:14:07Z"; |
| 69 | + private static final String UNIX_EPOCH_TIME = "1970-01-01T00:00:00Z"; |
69 | 70 | private static final Instant UNIX_2038_ROLLOVER = Instant.parse(UNIX_2038_ROLLOVER_TIME); |
| 71 | + private static final Instant UNIX_EPOCH = Instant.parse(UNIX_EPOCH_TIME); |
70 | 72 | private static final File DIR_OUTER = new File("outer"); |
71 | 73 | private static final File DIR_INNER = new File(DIR_OUTER, "inner"); |
72 | 74 | private static final File FILE_INNER = new File(DIR_INNER, "foo.txt"); |
@@ -231,12 +233,15 @@ static void checkFileTime(long now, long original) { |
231 | 233 |
|
232 | 234 | if (Math.abs(now - original) > PRECISION) { |
233 | 235 | // If original time is after UNIX 2038 32bit rollover |
234 | | - // and the now time is exactly the rollover time, then assume |
| 236 | + // and the now time is exactly the rollover time or UNIX epoch time, then assume |
235 | 237 | // running on a file system that only supports to 2038 (e.g.XFS) and pass test |
236 | | - if (FileTime.fromMillis(original).toInstant().isAfter(UNIX_2038_ROLLOVER) && |
237 | | - FileTime.fromMillis(now).toInstant().equals(UNIX_2038_ROLLOVER)) { |
238 | | - System.out.println("Checking file time after Unix 2038 rollover," + |
239 | | - " and extracted file time is " + UNIX_2038_ROLLOVER_TIME + ", " + |
| 238 | + Instant originalInstant = FileTime.fromMillis(original).toInstant(); |
| 239 | + Instant nowInstant = FileTime.fromMillis(now).toInstant(); |
| 240 | + if (originalInstant.isAfter(UNIX_2038_ROLLOVER) && |
| 241 | + (nowInstant.equals(UNIX_2038_ROLLOVER) || |
| 242 | + nowInstant.equals(UNIX_EPOCH))) { |
| 243 | + System.out.println("Checking file time after Unix 2038 rollover," + |
| 244 | + " and extracted file time is " + nowInstant + ", " + |
240 | 245 | " Assuming restricted file system, pass file time check."); |
241 | 246 | } else { |
242 | 247 | throw new AssertionError("checkFileTime failed," + |
|
0 commit comments