Static fields in specialized classes
Stephen Colebourne
scolebourne at joda.org
Tue Oct 14 14:46:33 UTC 2014
On 13 October 2014 19:19, Brian Goetz <brian.goetz at oracle.com> 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.
> Except for access through instances (yechh). Here, the compiler needs to
> rewrite any references to f.x (where f is an instance of a specialization of
> Foo) to Foo.x, and we're done.
There are a number of these edge cases in the Java language which are
almost never used and which Java the language would be far better off
without. Another is C style array locations, such as int
splitAndParse[](String str).
It seems entirely feasible to be more aggressive on these. Deprecate
in 9 (with warnings) and remove in 10. Isn't it time to take out some
of the garbage?
Stephen
More information about the valhalla-dev
mailing list