Skip to content

Commit 91df797

Browse files
koushikthirupatturBradford Wetmore
authored andcommitted
8357915: SecureRandom nextLong memory usage
Reviewed-by: wetmore
1 parent 92712ef commit 91df797

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
package java.security;
2727

28+
import jdk.internal.util.ByteArray;
2829
import sun.security.jca.GetInstance;
2930
import sun.security.jca.GetInstance.Instance;
3031
import sun.security.jca.Providers;
@@ -837,6 +838,16 @@ protected final int next(int numBits) {
837838
return next >>> (numBytes*8 - numBits);
838839
}
839840

841+
/**
842+
* {@inheritDoc}
843+
*/
844+
@Override
845+
public long nextLong() {
846+
byte[] b = new byte[8];
847+
nextBytes(b); // Calls engineNextBytes internally
848+
return ByteArray.getLong(b, 0);
849+
}
850+
840851
/**
841852
* Returns the given number of seed bytes, computed using the seed
842853
* generation algorithm that this class uses to seed itself. This

0 commit comments

Comments
 (0)