Class AssertingRandom
java.lang.Object
java.util.Random
com.carrotsearch.randomizedtesting.AssertingRandom
- All Implemented Interfaces:
Serializable
A random with a delegate, preventing
Random.setSeed(long)
and locked
to be used by a single thread.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StackTraceElement[]
private static final boolean
Enable paranoid mode when assertions are enabled.private final Random
private final String
private final WeakReference
<Thread> private boolean
Track out-of-context use of thisRandom
instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate final void
protected Object
clone()
void
destroy()
This object will no longer be usable after this method is called.boolean
int
hashCode()
static boolean
protected int
next
(int bits) boolean
void
nextBytes
(byte[] bytes) double
float
double
int
nextInt()
int
nextInt
(int n) long
nextLong()
(package private) static RuntimeException
void
setSeed
(long seed) toString()
-
Field Details
-
delegate
-
ownerRef
-
ownerName
-
allocationStack
-
valid
private volatile boolean validTrack out-of-context use of thisRandom
instance. This introduces memory barriers and scheduling side-effects but there's no other way to do it in any other way and sharing randoms across threads or test cases is very bad and worth tracking. -
assertionsEnabled
private static final boolean assertionsEnabledEnable paranoid mode when assertions are enabled.
-
-
Constructor Details
-
AssertingRandom
-
-
Method Details
-
next
protected int next(int bits) -
nextBoolean
public boolean nextBoolean()- Overrides:
nextBoolean
in classRandom
-
nextBytes
public void nextBytes(byte[] bytes) -
nextDouble
public double nextDouble()- Overrides:
nextDouble
in classRandom
-
nextFloat
public float nextFloat() -
nextGaussian
public double nextGaussian()- Overrides:
nextGaussian
in classRandom
-
nextInt
public int nextInt() -
nextInt
public int nextInt(int n) -
nextLong
public long nextLong() -
setSeed
public void setSeed(long seed) -
toString
-
equals
-
hashCode
public int hashCode() -
destroy
public void destroy()This object will no longer be usable after this method is called. -
checkValid
private final void checkValid() -
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
isVerifying
public static boolean isVerifying()- Returns:
- Return
true
if this class is verifying sharing and lifecycle assertions. - See Also:
-
noSetSeed
-