On Tue, 29 Jun 2021 19:57:24 GMT, Roger Riggs <rri...@openjdk.org> 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? > > 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 created by a `ClassLoader` again and again then it will be different each time. I'll investigate more. ------------- PR: https://git.openjdk.java.net/jdk17/pull/166