test/java/lang/Long/BitTwiddle.java
Print this page
rev 11823 : 8078672: Print and allow setting by Java property seeds used to initialize Random instances in java.lang numerics tests
Summary: Add ability to initial the random number generator from the system property "seed" and print to STDOUT the seed value actually used.
Reviewed-by: XXX
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -21,12 +21,15 @@
* questions.
*/
/*
* @test
- * @bug 4495754
- * @summary Basic test for long bit twiddling
+ * @library /lib/testlibrary/
+ * @build jdk.testlibrary.*
+ * @run main BitTwiddle
+ * @bug 4495754 8078672
+ * @summary Basic test for long bit twiddling (use -Dseed=X to set PRNG seed)
* @author Josh Bloch
* @key randomness
*/
import java.util.Random;
@@ -34,11 +37,11 @@
public class BitTwiddle {
private static final int N = 1000; // # of repetitions per test
public static void main(String args[]) {
- Random rnd = new Random();
+ Random rnd = RandomFactory.getRandom();
if (highestOneBit(0) != 0)
throw new RuntimeException("a");
if (highestOneBit(-1) != MIN_VALUE)
throw new RuntimeException("b");