Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8083976 | emb-9 | Daniel Fuchs | P3 | Resolved | Fixed | team |
JDK-8140883 | 8u91 | Ivan Gerasimov | P3 | Resolved | Fixed | b01 |
JDK-8133205 | 8u72 | Ivan Gerasimov | P3 | Resolved | Fixed | b01 |
JDK-8147215 | emb-8u91 | Ivan Gerasimov | P3 | Resolved | Fixed | b01 |
The following test:
for (Object[] test : new Object[][] {
{"Long.MAX_VALUE",Long.MAX_VALUE},
{"Long.MAX_VALUE-1",Long.MAX_VALUE-1},
{"1",1L},
{"0", 0L},
{"-1",-1L},
{"Long.MIN_VALUE+1",Long.MIN_VALUE+1},
{"Long.MIN_VALUE",Long.MIN_VALUE}
}) {
long millis = (Long)test[1];
System.err.println("Testing with " + test[0] +": "+millis+"L");
Instant i1 = Instant.ofEpochMilli(millis);
System.err.println("Instant.ofEpochMilli(): " + i1);
long seconds = i1.getEpochSecond();
System.err.println("Instant.getEpochSecond(): " + seconds);
System.err.println("millis/1000: " + millis/1000);
long millis2 = i1.toEpochMilli();
System.err.println("Instant.toEpochMilli(): " + millis2+"L");
if (millis2 != millis) {
throw new RuntimeException("Test failed for " + test[0]
+ "\n\texpected: "+millis+"L"
+ "\n\tactual: "+millis2+"L");
}
}
causes an arithmetic overflow for Long.MIN_VALUE+1 and Long.MIN_VALUE.
Exception in thread "main" java.lang.ArithmeticException: long overflow
at java.lang.Math.multiplyExact(Math.java:915)
at java.time.Instant.toEpochMilli(Instant.java:1232)
for (Object[] test : new Object[][] {
{"Long.MAX_VALUE",Long.MAX_VALUE},
{"Long.MAX_VALUE-1",Long.MAX_VALUE-1},
{"1",1L},
{"0", 0L},
{"-1",-1L},
{"Long.MIN_VALUE+1",Long.MIN_VALUE+1},
{"Long.MIN_VALUE",Long.MIN_VALUE}
}) {
long millis = (Long)test[1];
System.err.println("Testing with " + test[0] +": "+millis+"L");
Instant i1 = Instant.ofEpochMilli(millis);
System.err.println("Instant.ofEpochMilli(): " + i1);
long seconds = i1.getEpochSecond();
System.err.println("Instant.getEpochSecond(): " + seconds);
System.err.println("millis/1000: " + millis/1000);
long millis2 = i1.toEpochMilli();
System.err.println("Instant.toEpochMilli(): " + millis2+"L");
if (millis2 != millis) {
throw new RuntimeException("Test failed for " + test[0]
+ "\n\texpected: "+millis+"L"
+ "\n\tactual: "+millis2+"L");
}
}
causes an arithmetic overflow for Long.MIN_VALUE+1 and Long.MIN_VALUE.
Exception in thread "main" java.lang.ArithmeticException: long overflow
at java.lang.Math.multiplyExact(Math.java:915)
at java.time.Instant.toEpochMilli(Instant.java:1232)
- backported by
-
JDK-8083976 Instant.ofEpochMilli(millis).toEpochMilli() can throw arithmetic overflow in toEpochMilli()
-
- Resolved
-
-
JDK-8133205 Instant.ofEpochMilli(millis).toEpochMilli() can throw arithmetic overflow in toEpochMilli()
-
- Resolved
-
-
JDK-8140883 Instant.ofEpochMilli(millis).toEpochMilli() can throw arithmetic overflow in toEpochMilli()
-
- Resolved
-
-
JDK-8147215 Instant.ofEpochMilli(millis).toEpochMilli() can throw arithmetic overflow in toEpochMilli()
-
- Resolved
-
- duplicates
-
JDK-8074025 JCK test api/java_util/logging/LogRecord/index_Millis starts failing after JDK-8072645
-
- Closed
-