garbage collection and indy

Jochen Theodorou blackdrag at gmx.org
Tue Aug 22 20:06:16 UTC 2023


Hi,

since the group is still active (as is jvm-l) my question.

Let us say I have a Class Current and I create a class loader with the
defining classloader of Current as parent. in that loader I define a
class Foo with some instance methods.

Now I am getting myself a handle of a method of Foo, store the handle in
a static field of Current and null the classloader and any references to
Foo I might otherwise have in Current.

Is there any possible circumstance in which the class Foo can now be
garbage collected? My assumption is no.

And if this is done with invokedynamic and a callsite in Current is
created and I again produce the handle like above, do i correctly assume
that this does also mean a hard reference to the handle if I install
that handle as target?

And am I right that this strong reference logic also extends to var handles?

Let us assume I store the handle a class info in Foo and reference it
only through weak references. In the callsite in Current I would then
have to install a handle that gives me the weak reference and then I
would get the to be called handle from there? And dereference on every
call? Is a construct like that still going to inline?

bye Jochen


More information about the mlvm-dev mailing list