Skip to content

Commit 0b2aa1b

Browse files
committed
8263978: Clarify why 0 argument is ignored in SecureRandom::setSeed
Reviewed-by: valeriep
1 parent 15bcf6d commit 0b2aa1b

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/java.base/share/classes/java/security/SecureRandom.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,11 @@ public void setSeed(byte[] seed) {
730730
@Override
731731
public void setSeed(long seed) {
732732
/*
733-
* Ignore call from super constructor (as well as any other calls
734-
* unfortunate enough to be passing 0). It's critical that we
735-
* ignore call from superclass constructor, as digest has not
736-
* yet been initialized at that point.
733+
* Ignore call from super constructor as well as any other calls
734+
* unfortunate enough to be passing 0. All SecureRandom
735+
* constructors call `super(0)` which leads to `setSeed(0)`.
736+
* We either keep the object unseeded (in `new SecureRandom()`)
737+
* or we seed the object explicitly (in `new SecureRandom(byte[])`).
737738
*/
738739
if (seed != 0) {
739740
setSeed(longToByteArray(seed));

0 commit comments

Comments
 (0)