Static fields in specialized classes

Paul Sandoz paul.sandoz at
Tue Oct 14 21:08:43 UTC 2014

On Oct 14, 2014, at 8:13 PM, Brian Goetz <brian.goetz at Oracle.COM> wrote:

> OK, now that this is settled...  can I get some input on the original question?  Can anyone else thing of code that will need to be adjusted to support this view of the world?

Quick thoughts, need to think more thoroughly:

- could be some implications for Unsafe access, there is a shared memory location but the receivers might be different. The easy way out is to say "this is unsafe! you need to check beforehand what receiver to use for such cases".
- 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) 


> On 10/14/2014 10:46 AM, Stephen Colebourne wrote:
>> On 13 October 2014 19:19, Brian Goetz <brian.goetz at> wrote:
>>> Consider:
>>> class Foo<any T> {
>>>     public final static int x = System.currentTimeMillis();
>>> }
>>> Regardless of whether our implementation is by specialization or erasure (or
>>> both), logically there is just *one* field 'x' for any instantiation Foo<T>.
>> Just to note that I support this view of the world. I think the
>> alternatives would be surprising.

More information about the valhalla-dev mailing list