mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8263978: Clarify why 0 argument is ignored in SecureRandom::setSeed
Reviewed-by: valeriep
This commit is contained in:
parent
15bcf6d9f5
commit
0b2aa1b605
1 changed files with 5 additions and 4 deletions
|
@ -730,10 +730,11 @@ public class SecureRandom extends java.util.Random {
|
|||
@Override
|
||||
public void setSeed(long seed) {
|
||||
/*
|
||||
* Ignore call from super constructor (as well as any other calls
|
||||
* unfortunate enough to be passing 0). It's critical that we
|
||||
* ignore call from superclass constructor, as digest has not
|
||||
* yet been initialized at that point.
|
||||
* Ignore call from super constructor as well as any other calls
|
||||
* unfortunate enough to be passing 0. All SecureRandom
|
||||
* constructors call `super(0)` which leads to `setSeed(0)`.
|
||||
* We either keep the object unseeded (in `new SecureRandom()`)
|
||||
* or we seed the object explicitly (in `new SecureRandom(byte[])`).
|
||||
*/
|
||||
if (seed != 0) {
|
||||
setSeed(longToByteArray(seed));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue