8357915: SecureRandom nextLong memory usage

Reviewed-by: wetmore
This commit is contained in:
Koushik Thirupattur 2025-07-08 18:24:26 +00:00 committed by Bradford Wetmore
parent 92712ef45d
commit 91df797879

View File

@ -25,6 +25,7 @@
package java.security;
import jdk.internal.util.ByteArray;
import sun.security.jca.GetInstance;
import sun.security.jca.GetInstance.Instance;
import sun.security.jca.Providers;
@ -837,6 +838,16 @@ public class SecureRandom extends java.util.Random {
return next >>> (numBytes*8 - numBits);
}
/**
* {@inheritDoc}
*/
@Override
public long nextLong() {
byte[] b = new byte[8];
nextBytes(b); // Calls engineNextBytes internally
return ByteArray.getLong(b, 0);
}
/**
* Returns the given number of seed bytes, computed using the seed
* generation algorithm that this class uses to seed itself. This