- 
    Bug 
- 
    Resolution: Fixed
- 
     P4 P4
- 
    11, 17
- 
        b15
- 
        generic
- 
        generic
- 
        Verified
                    A DESCRIPTION OF THE PROBLEM :
When the distance between two instants is larger that Long.MAX_VALUE nanos, but less than Long.MAX_VALUE micros, ChronoUnit.MICROS.between() fails. This is due to the computation performed, which in OpenJDK 11 is in java.time.Instant, line 1148: nanosUntil(end) / 1000. nanosUntil overflows and throws an arithmetic exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Instant gregorianEpoch = Instant.EPOCH.minusSeconds(12219292800l);
Instant now = Instant.now();
long micros = ChronoUnit.MICROS.between(gregorianEpoch, now); -> Math.addExact throws ArithmeticException
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Correct long value returned
ACTUAL -
ArithmeticException
FREQUENCY : always
            
When the distance between two instants is larger that Long.MAX_VALUE nanos, but less than Long.MAX_VALUE micros, ChronoUnit.MICROS.between() fails. This is due to the computation performed, which in OpenJDK 11 is in java.time.Instant, line 1148: nanosUntil(end) / 1000. nanosUntil overflows and throws an arithmetic exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Instant gregorianEpoch = Instant.EPOCH.minusSeconds(12219292800l);
Instant now = Instant.now();
long micros = ChronoUnit.MICROS.between(gregorianEpoch, now); -> Math.addExact throws ArithmeticException
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Correct long value returned
ACTUAL -
ArithmeticException
FREQUENCY : always
- relates to
- 
                    JDK-8307466 java.time.Instant calculation bug in until and between methods -           
- Closed
 
-         
- links to
- 
                     Commit
        openjdk/jdk/81d2acee Commit
        openjdk/jdk/81d2acee
- 
                     Review
        openjdk/jdk/5396 Review
        openjdk/jdk/5396
- 
                     Review(master)
        openjdk/jdk/5396 Review(master)
        openjdk/jdk/5396