On 06/29/21 15:39, Weijun Wang wrote: > If I switch to a "non-weak" set or map, then it seems I can safely use > the source string as the key. Will using the Class object as a key prevent > them from unloading?
I understand that it's in principle possible for classes to get GC'd, though I don't know how often it happens in typical practical settings. This seems like a question to be approached from the angle of asking what the wanted semantics should be. What should be the effect on warning messages if class a.b.C is loaded and sets a security manager, and is later GC'd, and then a class also named a.b.C is later loaded, and sets a security manager? It seems like a preferred answer to that question would determine whether to make the set weak or not. Regards, -Chap