RFR: JDK-8288475: Initializing RandomGeneratorFactory.FactoryMapHolder fails if a SecurityManager is installed

Jaikiran Pai jpai at openjdk.org
Fri Jun 17 10:12:56 UTC 2022


On Fri, 17 Jun 2022 06:50:24 GMT, Johannes Kuhn <jkuhn at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/random/RandomGeneratorFactory.java line 165:
>> 
>>> 163:                 onlyBuiltIn = p -> VM.isSystemDomainLoader(p.type().getClassLoader());
>>> 164:             } else {
>>> 165:                 onlyBuiltIn = p -> true;
>> 
>> Should this variable be renamed to something else? Because right now it does the opposite of it's name. i.e. When `onlyBuiltIn` is set to `true`, like here, the code a few lines below which filters the stream accepts all `RandomGeneratorFactory` implementations that have been found.
>
> Good idea. Naming is hard - and I don't have a good name. Maybe `allowType`?
> 
> On second thought, I could change it to `Stream<...> s = ...; if (...) {s = s.filter(...)}`.

I think what you have with the filter call is fine. I think just renaming the `onlyBuiltIn` variable should be enough. Perhaps rename it to `acceptedProviders`?

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

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



More information about the security-dev mailing list