JDK 9 RFR of 8026236: Add PrimeTest for BigInteger [TEST-ONLY]

Brian Burkhalter brian.burkhalter at oracle.com
Tue Apr 22 23:48:09 UTC 2014


Issue:	https://bugs.openjdk.java.net/browse/JDK-8026236
Patch:	http://cr.openjdk.java.net/~bpb/8026236/webrev.00/

This test provides a rudimentary verification of isProbablePrime() by:

1 - checking that the first 100000 primes are correctly identified as probably prime
2 - checking that a random sample of positive integers does not reveal non-prime numbers which test as prime

The test allows for specification of an alternate source file of prime numbers if one wants to run it by hand. The file of primes included in the patch was limited to 100000 values in the interest of keeping the file size small.

I think that the range of random numbers used for the non-prime portion of the test (currently [0,100000)) needs to be reexamined, but I wanted to throw this out there for discussion as-is.

I’ve extended the use of the j.u.stream API to the entire test as recommended by Paul in http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-October/021859.html.



More information about the core-libs-dev mailing list