# HG changeset patch # User sherman # Date 1455590483 28800 # Node ID 9fdca6a099c17fa65b798282c8b8e957e69b4147 # Parent 6ed1de57b086a5eca4202d3e4b14f4ea1b08d2bb 8135108: java/util/zip/TestLocalTime.java fails intermittently with Invalid value for NanoOfSecond Reviewed-by: darcy diff -r 6ed1de57b086 -r 9fdca6a099c1 jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java --- a/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java Mon Feb 15 13:37:22 2016 -0800 +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java Mon Feb 15 18:41:23 2016 -0800 @@ -227,12 +227,12 @@ if (year < 0) { this.xdostime = DOSTIME_BEFORE_1980; } else { - this.xdostime = (year << 25 | + this.xdostime = ((year << 25 | time.getMonthValue() << 21 | time.getDayOfMonth() << 16 | time.getHour() << 11 | time.getMinute() << 5 | - time.getSecond() >> 1) + time.getSecond() >> 1) & 0xffffffffL) + ((long)(((time.getSecond() & 0x1) * 1000) + time.getNano() / 1000_000) << 32); } diff -r 6ed1de57b086 -r 9fdca6a099c1 jdk/test/java/util/zip/TestLocalTime.java --- a/jdk/test/java/util/zip/TestLocalTime.java Mon Feb 15 13:37:22 2016 -0800 +++ b/jdk/test/java/util/zip/TestLocalTime.java Mon Feb 15 18:41:23 2016 -0800 @@ -23,7 +23,7 @@ /* * @test - * @bug 8075526 + * @bug 8075526 8135108 * @key intermittent * @summary Test timestamp via ZipEntry.get/setTimeLocal() */ @@ -41,6 +41,7 @@ try { LocalDateTime ldt = LocalDateTime.now(); test(getBytes(ldt), ldt); // now + ldt = ldt.withYear(1968); test(getBytes(ldt), ldt); ldt = ldt.withYear(1970); test(getBytes(ldt), ldt); ldt = ldt.withYear(1982); test(getBytes(ldt), ldt); @@ -55,6 +56,13 @@ testWithTZ(tz, ldt.withYear(2037)); testWithTZ(tz, ldt.withYear(2100)); testWithTZ(tz, ldt.withYear(2106)); + + // for #8135108 + ldt = LocalDateTime.of(2100, 12, 06, 12, 34, 34, 973); + test(getBytes(ldt), ldt); + ldt = LocalDateTime.of(2106, 12, 06, 12, 34, 34, 973); + test(getBytes(ldt), ldt); + } finally { TimeZone.setDefault(tz0); }