Re: RFR: 8273369: Computing micros between two instants unexpectedly overflows for some cases [v2]
On Tue, 7 Sep 2021 18:46:56 GMT, Roger Riggs wrote: >> Naoto Sato has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Added a constant for nanos per micro. > > src/java.base/share/classes/java/time/Instant.java line 1170: > >> 1168: long secsDiff = Math.subtractExact(end.seconds, seconds); >> 1169: long totalMicros = Math.multiplyExact(secsDiff, >> NANOS_PER_SECOND / 1000); >> 1170: return Math.addExact(totalMicros, (end.nanos - nanos) / 1000); > > Can you define NANOS_PER_MICRO, the others conversions use predefined > constants. Defined it as a private field in `Instant`. - PR: https://git.openjdk.java.net/jdk/pull/5396
Re: RFR: 8273369: Computing micros between two instants unexpectedly overflows for some cases [v2]
> Please review the fix to the issue. Avoiding overflow by not calling > nanosUntil() directly, which will overflow beyond Long.MAX_VALUE difference > in nano unit. Naoto Sato has updated the pull request incrementally with one additional commit since the last revision: Added a constant for nanos per micro. - Changes: - all: https://git.openjdk.java.net/jdk/pull/5396/files - new: https://git.openjdk.java.net/jdk/pull/5396/files/09d9b257..4b874ff6 Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=5396=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk=5396=00-01 Stats: 5 lines in 1 file changed: 4 ins; 0 del; 1 mod Patch: https://git.openjdk.java.net/jdk/pull/5396.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5396/head:pull/5396 PR: https://git.openjdk.java.net/jdk/pull/5396