"Model 2" prototype status

Brian Goetz brian.goetz at oracle.com
Fri Aug 7 18:29:14 UTC 2015

> But my question stands: given the scenario, where do _t and _x live?
> Foo<String>._t vs Foo<int>._t and Foo<String>_x and Foo<int>._x? How
> would it work with reflection?

In the current prototype, they are shared across instantiations and are 
stored as static members on the erased class (Foo).  The compiler 
translates a static field access Foo<int>.x as "getfield Foo.x". 
Reflection on Foo.class will find these members; reflection on 
Foo<int>.class will not currently.  This is good enough for purposes of 
our current prototype.

We're investigating (that's code for "that's all I'm ready to say about 
it for now") some less ad-hoc ways of representing static members, as 
well as investigating how we're going to address the issue of 
per-instantiation values.  Stay tuned.

More information about the valhalla-dev mailing list