Draft JEP: Primitive Types in Patterns, instanceof, and switch (Second Preview)
Remi Forax
forax at univ-mlv.fr
Fri Aug 30 21:31:53 UTC 2024
----- Original Message -----
> From: "Stephan Herrmann" <stephan.herrmann at berlin.de>
> To: "Brian Goetz" <brian.goetz at oracle.com>, "amber-spec-experts" <amber-spec-experts at openjdk.org>
> Sent: Friday, August 30, 2024 9:58:42 PM
> Subject: Re: Draft JEP: Primitive Types in Patterns, instanceof, and switch (Second Preview)
Hello Stephan,
> Why should it be a bug to inform the user about bad style?
>
> Note, that users are free to chose the severity of this problem as one of Error,
> Warning, Info or Ignore.
For me this message by ecj is misleading :
- you may want to capture a wildcard bounded by Integer using a named type parameter,
List<? extends Integer> list = ...
capture(list);
<T extends Integer> void capture(List<T> list) {
...
}
- the JLS explicitly says that removing final from a class is a backward compatible change, so maybe in the future the final class will not be a final anymore. That's why a class being final is not something which is part of the type system.
regards,
Rémi
>
>
> Am 30.08.24 um 21:55 schrieb Brian Goetz:
>> That's probably a (well intentioned!) ECJ bug!
>>
>>
>> On 8/30/2024 3:52 PM, Stephan Herrmann wrote:
>>> Thanks for clarifying.
>>>
>>> FWIW ecj informs me:
>>>
>>> The type parameter T should not be bounded by the final type Integer. Final
>>> types cannot be further extended
>>>
>>> :)
>>>
>>> Am 30.08.24 um 21:47 schrieb Brian Goetz:
>>>> 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
>>>>>
>>>>
>>>
More information about the amber-spec-experts
mailing list