On Tue, 8 Oct 2024 17:10:43 GMT, Ramkumar Sunderbabu <rsunderb...@openjdk.org> 
wrote:

> The time difference check might fail for scenarios such as batch compilation. 
> It is safer to give a bigger allowance of 10 seconds instead of 0.1 sec.
> 
> Testing: The test was run for 100 times with -Xcomp option.

test/jdk/java/time/tck/java/time/TCKInstant.java line 193:

> 191:         Instant test = Instant.now();
> 192:         long diff = Math.abs(test.toEpochMilli() - 
> expected.toEpochMilli());
> 193:         assertTrue(diff < 10_000);  // less than 10 secs

Given arbitrary delays between the two executions; the premise of the test 
itself is suspect; especially if the allowed time is increased.  I think the 
test is supposed to be testing that the default clock for Instant.now() is the 
SystemUTC clock.
I'd expect expected to be less than or equal to test.
The use of math.abs allows the clock to go backwards; that might happen if the 
time was re-set manually.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21413#discussion_r1792423559

Reply via email to