Draft JEP: Primitive Types in Patterns, instanceof, and switch (Second Preview)

Brian Goetz brian.goetz at oracle.com
Fri Aug 30 19:47:19 UTC 2024


I had exactly the same confusion when I read those words.  Alex set me 
straight.

     <T extends Integer> int asInt(T t) { return t; }

Here, we go from T to Integer (a widening reference conversion), then to 
int (an unboxing conversion).

On 8/30/2024 3:44 PM, Stephan Herrmann wrote:
> The other day I stumbled upon this in the JLS changes for the first 
> preview (JEP 455):
>
> * a widening reference conversion followed by an unboxing conversion
> * a widening reference conversion followed by an unboxing conversion, 
> then followed by a widening primitive conversion
>
> I fail to imagine any type that can be widened to a boxing type. 
> What's going on here?
>
> best,
> Stephan
>
>
> Am 30.08.24 um 15:55 schrieb Angelos Bimpoudis:
>> Dear experts,
>>
>> A draft JEP for the second preview of primitive types in patterns, 
>> instanceof, and switch is now available. We propose to preview it for 
>> a second time with no changes relative to JDK 23. This feature aligns 
>> what instanceof and pattern matching mean across all types. This 
>> second preview, unchanged, gives ample time to amber experts to 
>> express their feedback.
>>
>> https://bugs.openjdk.org/browse/JDK-8335876
>>
>> Let us know of your feedback.
>>
>> Thank you,
>> Angelos
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-experts/attachments/20240830/e4c35d76/attachment-0001.htm>


More information about the amber-spec-experts mailing list