Static fields in specialized classes
Brian Goetz
brian.goetz at oracle.com
Tue Oct 14 21:45:12 UTC 2014
> - care might need to be taken with class initlization, static access
> should trigger initialisation before that access occurs but does this
> mean both Foo and Foo<int> should be initialized if access occurs
> from the latter? (not sure if you already have this aspect covered)
I think we have this one covered. The compiler and specializer
cooperate to have this effect.
- All declarations of static members (fields and methods, including
<clinit>) are stripped out during specialization. So the static members
exist only on the template (base) class.
- All references to static members (whether through classes or through
instances) are rewritten to directly reference the template class.
- Specialized classes acquire a <clinit> that does "LDC
template.class", idempotently forcing the template class to be
initialized if it is not already.
This is all implemented in the prototype as of today.
More information about the valhalla-dev
mailing list