Static fields and specialization

MacGregor, Duncan (GE Energy Management) duncan.macgregor at ge.com
Mon Jan 12 15:41:35 UTC 2015


I don¹t think anybody is suggesting that they don¹t play together, but
while many problems can be resolved over the small set of primitive types
by explicitly create separate static fields for each type if need be, this
technique does not scale once arbitrary value types have been introduced.

At that point we can¹t simply write

static final MethodHandle mhObj =...
Static final MethodHandle mhInt =...

And so on, and rely on layering to let us specify specialised methods that
use these, but have to start writing something more like

Final static <any T> MethodHandle mh =...

Duncan.

On 12/01/2015 15:32, "Brian Goetz" <brian.goetz at oracle.com> wrote:

>> Yes, but you can not create specialized implementations for user defined
>> value types.
>
>Where do you get this idea, that value types and specialization don't
>play together?
>
>Also, note that allocation for value types doesn't allocate.  So your
>mental performance model about what "new Optional<int>()" costs is
>probably just wrong.
>




More information about the valhalla-dev mailing list