--- jsr166/src/test/tck/ThreadLocalRandomTest.java 2017/09/19 20:10:49 1.25 +++ jsr166/src/test/tck/ThreadLocalRandomTest.java 2017/10/03 22:27:04 1.26 @@ -385,4 +385,24 @@ public class ThreadLocalRandomTest exten fail("all threads generate the same pseudo-random sequence"); } + /** + * Repeated calls to nextBytes produce at least values of different signs for every byte + */ + public void testNextBytes() { + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + int n = rnd.nextInt(20); + byte[] bytes = new byte[n]; + outer: + for (int i = 0; i < n; i++) { + for (int tries = NCALLS; tries-->0; ) { + byte before = bytes[i]; + rnd.nextBytes(bytes); + byte after = bytes[i]; + if (after * before < 0) + continue outer; + } + fail("not enough variation in random bytes"); + } + } + }