ModuleLayer.Controller strongly references Module

Michał Kłeczek michal at kleczek.org
Wed Nov 24 18:14:13 UTC 2021


> On 24 Nov 2021, at 13:33, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>> 
>> 1. Controller is created upon ML construction and returned from static ML.defineModules methods.
>> 2. Created two controller liveness tests (they rely on System.gc() though - not sure if there are some tricks to test it reliably).
> 
> I read your mail about "smart proxy" classes and lazy downloading of modules. I don't have an opinion at this time on whether this is worth doing or not.

For sure it’s fun :)

Regardless of “smart proxies” the lifetime of ML.Controller should be - if not fixed - at least be documented IMHO. Right now it’s a minefield.

> 
> If you want to experiment with patches then add a volatile field to ML and only set it when VM.isBooted() is true. In order words, let the ML.Controller for the boot layer be GC'ed as it is now (it would be attractive nuisance to keep it alive). There are many tests in the test/jdk tree that check that a weak ref is cleared, there is also some test infrastructure to help, so you might want to look at those.

See attached patch.

I am now curious why leaving controller for boot layer is to be avoided.

-- Michal



More information about the jigsaw-dev mailing list