ModuleLayer.Controller strongly references Module
michal at kleczek.org
Sun Nov 21 13:27:36 UTC 2021
I am looking for a way to associate ModuleLayer.Controller with a Module (or ModuleLayer) in such a way that it won’t disable garbage collection of Modules and ModuleLayers.
WeakHashMap<ModuleLayer, ModuleLayer.Controller> won’t work as Controller strongly references its ModuleLayer (which in turn strongly references Modules).
WeakHashMap<ModuleLayer, WeakReference<ModuleLayer.Controller>> won’t work either cause controller will be garbage collected.
So far I only came up with subclassing a ModuleReference and keeping the reference to the controller there. This won’t work in case when ModuleLayer.configuration() is used a a parent configuration.
Am I missing something obvious here?
More information about the discuss