On 05/05/2014 11:17 PM, Brian Burkhalter wrote:
Joe / Paul,

Thanks for the comments. This an aggregate response to your two
messages. An updated version of the patch is here:

http://cr.openjdk.java.net/~bpb/8026236/webrev.03/

The command line parsing is off by one, I think, it should check for >= instead of >:

  54         // Prepare arguments
55 int upperBound = args.length > 1 ? Integer.valueOf(args[0]) : DEFAULT_UPPER_BOUND; 56 int certainty = args.length > 2 ? Integer.valueOf(args[1]) : DEFAULT_CERTAINTY; 57 boolean parallel = args.length > 3 ? Boolean.valueOf(args[2]) : true;

I think this line should go, it doesn't match the shifted indexing:

  98         //bs.set(0, 2, true);

There are some very long lines:

120 NavigableSet<BigInteger> primes = bs.stream().mapToObj(p -> BigInteger.valueOf(p + 2)).collect(toCollection(TreeSet::new));

180 List<BigInteger> bigInts = (new SplittableRandom()).ints(NUM_NON_PRIMES, 2, maxPrime).mapToObj(BigInteger::valueOf).filter(b -> !b.isProbablePrime(certainty)).collect(toList());


The arithmetic in checkPrime() is unnecessary because isProbablePrime() will never report a prime as a non-prime (the Monte-Carlo vs Las Vegas thing), so the count will always be exact because you feed it only primes. It is impossible to check for the expected number of failures (non-primes reported as primes) in checkNonPrimes() because this would result in a test that fails sporadically.

--
Florian Weimer / Red Hat Product Security Team

Reply via email to