How do I keep a class available to unload while keeping a MethodHandles.Lookup of it?
I have a library where a class can consent to full access of private members by registering its
MethodHandles.lookup()
in its static initializer. Something like this:
The private lookup gets stored inside a Map<Class, MethodHandles.Lookup>
. I want to be able to give the class the freedom to unload. So when all references to the class loader and the class itself is gone.
Issue is that Lookup contains a reference to the class so I would need a weakly referenced key and value map. (that is not the issue, already have that) If I do that though, the lookup itself will be randomly forgotten so that kind of defeats the whole purpose of providing it on load.
Any ideas on how to best handle this?1 Reply
⌛
This post has been reserved for your question.
Hey @LapisSea™! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.