Q: Why are $assertionsDisabled nested classes loaded eagerly by interface static initializers?

David Lloyd david.lloyd at redhat.com
Thu Jan 29 14:00:09 UTC 2026


On Wed, Jan 28, 2026 at 6:08 PM Chen Liang <chen.l.liang at oracle.com> wrote:

> Hi David, a dynamic constant does have the advantage of bypassing some
> circular initialization issues. However, such a constant still must be
> initialized by the time the class finishes initialization. The benefits of
> a dynamic constant are not helpful unless we adjust the JLS.
>

Agreed, the JLS would indeed need to be updated (in either case) to allow
for lazy initialization. I think it could be a worthwhile update though.


> In addition, a synthetic field can be accessed by other classes and
> interfaces in the same nest; not so for dynamic constants without an
> accessor method.
>

I see: without some kind of accessor, nestmates would have to independently
determine assertion status which could conceivably be subject to a race
condition.
-- 
- DML • he/him
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20260129/1174c8c3/attachment-0001.htm>


More information about the compiler-dev mailing list