On Jan 9, 2017, at 4:36 PM, Jochen Theodorou <blackd...@gmx.org> wrote:
> Hi all,
> This is kind of a feature request... What I would like to have is a new 
> Reference variant that allows me to keep an instance alive for as long as the 
> class of the object is alive, without the instance keeping the class alive.
> In the end I would like to be able to store values, but don´t keep the 
> classes involved from being garbage collected. I am especially thinking here 
> about a combination of ClassValue and this Ephemeron (?) that allows me to 
> cache values on classes, without preventing class unloading.
> Is there any chance for this making its way into the JVM? What would prevent 
> this?

This is a good thing to file a JEP on.

I think the main reason we don't have such a thing yet is the extraordinary 
difficulty of correctly specifying such a thing, where "correct" means "covers 
enough use cases to be worth it" (your example is just one use case) and also 
means "has a natural implementation that is not too complex".  And also means 
"is unambiguous and precise".  And, come to think of it, also means "fits into 
the Java ecosystem, especially with respect to tradeoffs involving determinism 
or static typing".  In the case of ephemerons there is some good literature but 
nobody has translated it into a compelling Java API.  AFAIK.  Anyway, a correct 
spec. is the bottleneck.  After that it's just budgeting resources and/or 
awaiting volunteers.

— John
mlvm-dev mailing list

Reply via email to