RFR: 8324648: Avoid NoSuchMethodError when instantiating NativePRNG [v4]

Valerie Peng valeriep at openjdk.org
Wed Feb 7 18:40:02 UTC 2024


On Wed, 7 Feb 2024 09:49:10 GMT, Oli Gillespie <ogillespie at openjdk.org> wrote:

>> A typical call to `new SecureRandom()` is slowed down by looking for a constructor in NativePRNG which takes `java.security.SecureRandomParameters`. NativePRNG does not have such a constructor, so the search fails [here](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/security/Provider.java#L1951-L1957), incurring all the cost of the lookup and creating a subsequent exception.
>> 
>> Creating a dummy constructor which takes and ignores this parameter will speed up `new SecureRandom()` calls significantly. 
>> 
>> The benchmark from https://github.com/openjdk/jdk/pull/17559 shows around 80% reduction in time taken to create a new SecureRandom with NativePRNG (default on my machine).
>> 
>> 
>> Before
>> SecureRandomBench.newSecureRandom  avgt  2930 ± 50 ns/op
>> 
>> After
>> SecureRandomBench.newSecureRandom  avgt  510 ± 16 ns/op
>
> Oli Gillespie has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove super() calls

Marked as reviewed by valeriep (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/17560#pullrequestreview-1868524507



More information about the security-dev mailing list