Static fields in specialized classes

Vitaly Davidovich vitalyd at gmail.com
Mon Oct 13 19:20:26 UTC 2014


Sure, I don't dismiss the historical aspect of this.  However, I don't
necessarily think this should be a barrier if generics were to be reified
or specialization introduced.  In that case, people should become aware of
what's happening with their static fields, and once they do, I don't think
they'll find it unintuitive given the new context.  I think it's intuitive
to think of generic types (in a specialized/reified world) as
recipes/templates/"super macros" for concrete instantiations, and given
that, it makes sense (to me, at least) that the static fields are
replicated across the actual instantiations.

On Mon, Oct 13, 2014 at 3:13 PM, Brian Goetz <brian.goetz at oracle.com> wrote:

> As a user, I would *not* expect that there's just one fooCount field for
>> all Foo<T> instances.
>>
>
> Except that's how generics have worked in Java since 2004.  Do you propose
> that existing generic code with statics should change how it behaves?  Or
> are you suggesting that the existing behavior is also counterintuitive?
>


More information about the valhalla-dev mailing list