Simplifying reified generics with partial specialization

Ron Pressler ron at paralleluniverse.co
Mon Jan 5 20:00:41 UTC 2015


  > it would be a bad idea to have occurrences of “int" which actually mean int|null.


They don’t. ArrayList<int> is specialized and cannot hold nulls, and while it would implement List<Integer>, it throws an NPE when trying to store a null, just like when trying to auto-unbox a null Integer. A List<Integer> is perfectly allowed to behave this way.

But I suggest that, per Brian’s request, we continue this discussion elsewhere. This isn’t the place for protracted discussions.







> On Jan 5, 2015, at 9:52 PM, Gavin King <gavin at hibernate.org> wrote:
> 
> 
> On Mon, Jan 5, 2015 at 1:10 PM, Ron Pressler <ron at paralleluniverse.co> wrote:
> 
> 
>> This would mean that ArrayList<int> will implement List<Integer> (and will
>> therefore extend List and List<?>)
>> 
>> 
>> 
> 
> 
> Ron I think this would be a bad idea. Yes, I know that Java
> unfortunately doesn't provide a typesafe null value, but I still think
> that it would be a bad idea to have occurrences of "int" which
> actually mean int|null. I think there's a really strong precedent in
> the language that ints can't be null.
> 
> 
> OTOH, perhaps it would be viable to make ArrayList<int> a subtype of
> ArrayList<? extends Integer>.
> 
> 




More information about the valhalla-dev mailing list