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 booleanEnable paranoid mode when assertions are enabled.private final Randomprivate final Stringprivate final WeakReference<Thread> private booleanTrack out-of-context use of thisRandominstance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate final voidprotected Objectclone()voiddestroy()This object will no longer be usable after this method is called.booleaninthashCode()static booleanprotected intnext(int bits) booleanvoidnextBytes(byte[] bytes) doublefloatdoubleintnextInt()intnextInt(int n) longnextLong()(package private) static RuntimeExceptionvoidsetSeed(long seed) toString()
-
Field Details
-
delegate
-
ownerRef
-
ownerName
-
allocationStack
-
valid
private volatile boolean validTrack out-of-context use of thisRandominstance. 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
-
nextBoolean
public boolean nextBoolean()- Overrides:
nextBooleanin classRandom
-
nextBytes
-
nextDouble
public double nextDouble()- Overrides:
nextDoublein classRandom
-
nextFloat
-
nextGaussian
public double nextGaussian()- Overrides:
nextGaussianin classRandom
-
nextInt
-
nextInt
-
nextLong
-
setSeed
-
toString
-
equals
-
hashCode
-
destroy
public void destroy()This object will no longer be usable after this method is called. -
checkValid
private final void checkValid() -
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
isVerifying
public static boolean isVerifying()- Returns:
- Return
trueif this class is verifying sharing and lifecycle assertions. - See Also:
-
noSetSeed
-