Static fields and specialization

Palo Marton palo.marton at
Sat Jan 10 22:23:51 UTC 2015

I think there is no other solution to this except to somehow allow some
static fields to be specialized. Soutions with CHM or ClassValue will mean
serious performance degradation.

On Saturday, January 10, 2015, Brian Goetz <brian.goetz at> wrote:

> I think his question was: how will we maintain the optimization where
> Optional.empty() returns a statically-allocated, shared singleton instance
> when the value being returned is type-specific.
> On 1/10/2015 5:08 PM, Ben Lewis wrote:
>> Static fields cannot be specialized as what type would the field be
>> Optional, Optional<int> or Optional<someValueType>. This approach has
>> problems with generics anyways, both Optional.empty() and
>> Collections.empty*() are methods to maintain type safety as stated in the
>> javadocs.
>> On Sun, Jan 11, 2015 at 10:34 AM, Palo Marton <palo.marton at>
>> wrote:
>>  If static fields are not specialized, how will you handle things
>>> like Optional.EMPTY?

More information about the valhalla-dev mailing list