8130914: java/util/zip/TestExtraTime.java fails with "java.lang.RuntimeException: setTime should make getLastModifiedTime return the specified instant: 3078282244456 got: 3078282244455"
authorsherman
Wed, 22 Jul 2015 21:11:38 -0700
changeset 31820 f8214072b376
parent 31819 ba7cde5a611a
child 31821 2bd5e805e5f1
8130914: java/util/zip/TestExtraTime.java fails with "java.lang.RuntimeException: setTime should make getLastModifiedTime return the specified instant: 3078282244456 got: 3078282244455" Summary: fixed the 32-bit overflow. Reviewed-by: rriggs
jdk/src/java.base/share/classes/java/util/zip/ZipUtils.java
jdk/test/java/util/zip/TestExtraTime.java
--- a/jdk/src/java.base/share/classes/java/util/zip/ZipUtils.java	Wed Jul 22 21:43:33 2015 +0000
+++ b/jdk/src/java.base/share/classes/java/util/zip/ZipUtils.java	Wed Jul 22 21:11:38 2015 -0700
@@ -99,9 +99,9 @@
         if (year < 1980) {
             return ZipEntry.DOSTIME_BEFORE_1980;
         }
-        return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
-               d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
-               d.getSeconds() >> 1;
+        return ((year - 1980) << 25 | (d.getMonth() + 1) << 21 |
+                d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
+                d.getSeconds() >> 1) & 0xffffffffL;
     }
 
     /**
--- a/jdk/test/java/util/zip/TestExtraTime.java	Wed Jul 22 21:43:33 2015 +0000
+++ b/jdk/test/java/util/zip/TestExtraTime.java	Wed Jul 22 21:11:38 2015 -0700
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 4759491 6303183 7012868 8015666 8023713 8068790 8076641 8075526
+ * @bug 4759491 6303183 7012868 8015666 8023713 8068790 8076641 8075526 8130914
  * @summary Test ZOS and ZIS timestamp in extra field correctly
  */