Nest host validation vs NestHost attribute performed by Lookup::defineHiddenClass
Mandy Chung
mandy.chung at oracle.com
Tue Oct 1 18:04:22 UTC 2019
On 10/1/19 3:11 AM, Peter Levart wrote:
> Imagine a situation where a hidden class HC1 is defined in it's own
> nest. Then this HC1 is used as a LC in a Lookup to define another
> hidden class HC2 to be part of this nest (HC1, HC2). What should
> HC2.getNestHost() return? If it returns HC1, then HC2 is effectively
> preventing HC1 to be unloaded.
>
There is no restriction what a hidden class can call, for example, using
lambda or method reference, which may call a framework library to
generate HC2. HC1 and HC2 should be unloaded when both classes become
unreachable. Do I miss the issue you tried to point out?
(Note that defineHiddenClass takes an enum constant to specify if the
hidden is a dynamic nestmate and/or a weak class to specify if it's
weakly referenced by the class loader. In other words, a dynamic
nestmate has the same lifecycle as its defining class loader if not
specified weak.)
Mandy
More information about the valhalla-dev
mailing list