On Tue, 29 Jun 2021 21:18:35 GMT, Weijun Wang <wei...@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