-
CSR
-
Resolution: Unresolved
-
P4
-
None
-
minimal
-
Java API
-
SE
Summary
SecureRandom nextLong memory usage enhancement.
Problem
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.
Solution
Provide an explicit implementation of the nextLong() method in SecureRandom, which is currently inherited from Random. The new implementation overrides this method to call nextBytes() with an 8-byte array and converts the resulting bytes into a single long value, eliminating the need for multiple allocations.
Specification
This method overrides the implementation inherited from {@code Random} to avoid double allocation. It generates a single 8-byte value using {@code nextBytes()} and returns the result as a {@code long}.
/** * {@inheritDoc} */ @Override public long nextLong() { }
- csr of
-
JDK-8357915 SecureRandom nextLong memory usage
-
- In Progress
-