Future of primitive specialization (generics) and null-restriction

Brian Goetz brian.goetz at oracle.com
Mon May 22 16:41:49 UTC 2023


These are very fair questions, but its still early to answer these.  
I'll try to sketch where we are on these questions.

1.  The previous model ("primitive classes") tried to directly model the 
int/Integer divide.  One of the supposed benefits is that the 
int/Integer distinction could go away, but as it turns out, this wasn't 
necessarily even 100% true.

The current model breaks the divide down into more fundamental 
distinctions (declaration-site initialization safety + use-site 
nullity), which is a big improvement, but makes it even less likely that 
we will truly achieve `int` being an alias for `Integer!`.  The main 
question is where to put the (now much smaller) seam; there are tradeoffs.

2.  The exact status of the legacy primitives in generics depends on 
some decisions coming out of (1), TBD.  Again, tradeoffs.

On 5/22/2023 11:43 AM, - wrote:
> Hello,
> Since we have null-restricted types now, I have a few questions about
> its implications on existing primitives and expanded generics:
>
> 1. Are Integer.TYPE (int.class) primitives etc. now the same as the
> null-restricted type of Integer etc. value-type wrappers?
> 2. Will type parameterization like List<int> be written like
> List<Integer!> (null-restricted specialization), effectively
> invalidating JEP 218, as the same performance can now be achieved with
> value-type parameterization in VM without invasively changing the type
> hierarchy assumptions of generics? (JEP 8261529 doesn't appear updated
> to the current null-restriction model)
>
> Curious,
> Chen Liang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-dev/attachments/20230522/385c3d49/attachment.htm>


More information about the valhalla-dev mailing list