Static fields and specialization

Richard Warburton richard.warburton at gmail.com
Mon Jan 12 11:35:24 UTC 2015


Hi,

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.
>

In the case of Optional.empty() and others like Collections.emptyList()
it's a method that you're invoking. There is no need to implement static
field specialization. You can just get your specialized implementations to
return different singleton instances. Ok - so this means you now have 9
empty instances rather than 1 but that's basically nothing in terms of
memory consumption. In the case of Optional you already have manual
specialisation for 3 primitive cases in the form of Optionalint and friends
so its really 9 rather than 4 anyway.

regards,

  Richard Warburton

  http://insightfullogic.com
  @RichardWarburto <http://twitter.com/richardwarburto>


More information about the valhalla-dev mailing list