RFR: 8357915: SecureRandom nextLong memory usage

Koushik Muthukrishnan Thirupattur duke at openjdk.org
Mon Jun 30 05:32:26 UTC 2025


SecureRandom uses straightforward implementations inherited from Random but in the process does double the memory allocations necessary.
The delegation to SecureRandom.engineNextBytes does not provide `int` or `long` values, the caller must allocate a byte array and assemble the value itself.
So added an implementation in SecureRandom that call nextBytes(8 bytes) and then convert that to a long.

-------------

Commit messages:
 - 8357915: SecureRandom nextLong memory usage
 - Merge branch 'master' into 8357915
 - 8357915: SecureRandom nextLong memory usage
 - 8357915: SecureRandom nextLong memory usage

Changes: https://git.openjdk.org/jdk/pull/26005/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26005&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8357915
  Stats: 8 lines in 1 file changed: 8 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/26005.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26005/head:pull/26005

PR: https://git.openjdk.org/jdk/pull/26005


More information about the security-dev mailing list