Allow setting seed only once, as it is set from superclass constructor
Add tests for Java<->Kotlin Random wrappers. #KT-29520 Fixed
This commit is contained in:
@@ -75,7 +75,13 @@ private class KotlinRandom(val impl: Random) : java.util.Random() {
|
||||
impl.nextBytes(bytes)
|
||||
}
|
||||
|
||||
private var seedInitialized: Boolean = false
|
||||
override fun setSeed(seed: Long) {
|
||||
throw UnsupportedOperationException("Setting seed is not supported.")
|
||||
if (!seedInitialized) {
|
||||
// ignore seed value from constructor
|
||||
seedInitialized = true
|
||||
} else {
|
||||
throw UnsupportedOperationException("Setting seed is not supported.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user