[jdk17] RFR: 8269543: The warning for System::setSecurityManager should only appear once for each caller

Alan Bateman alanb at openjdk.java.net
Wed Jun 30 06:35:05 UTC 2021


On Tue, 29 Jun 2021 21:18:35 GMT, Weijun Wang <weijun at openjdk.org> wrote:

>> Using a synchronized WeakHashMap with the class as the key would not prevent class unloading.
>> Using a non-weak set or map to strings would keep the strings around for the life of the runtime.
>
> I hope this is uncommon but if that class is loaded by a `ClassLoader` again and again then it will be different each time. I'll investigate more.

WeakHashMap<Class<?>, Boolean>, where the key is the caller, should be okay (assume synchronization of course). Even with applications that do call setSecurityManager then the map is probably going to be one entry. I wouldn't expect it is common to create custom class loaders that load code that sets a security manager, meaning it is more likely that the container sets the SM rather have each plugin/application/whatever try to set the system-wide SM.

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

PR: https://git.openjdk.java.net/jdk17/pull/166



More information about the security-dev mailing list