RFR: 8263358: Update java.lang to use instanceof pattern variable [v5]

Jan Lahoda jlahoda at openjdk.java.net
Mon Mar 15 11:42:08 UTC 2021


On Mon, 15 Mar 2021 11:09:45 GMT, Rémi Forax <github.com+828220+forax at openjdk.org> wrote:

>>> I think it's a bug in javac, it should not even raise a warning but an error.
>>> But the spec is not fully clear.
>> 
>> If you think that it's a bug, consider providing feedback to authors of JEP 394:
>> 
>>> Other refinements may be incorporated based on further feedback.
>> 
>> I find it hard to believe that authors didn't consider generic use case (even though JEP 394 doesn't have examples of that).
>
> We have considered generics, that why parameterized generics with another type arguments are forbidden, but i think we have forgotten raw types.

I don't think that cast from `Object` to a raw type is unchecked, so as error does not seem warranted to me.

However, I agree javac should produce the rawtype warning for rawtypes in pattern matching instanceof, because we are introducing a new variable (and casting). I've filled:
https://bugs.openjdk.java.net/browse/JDK-8263590

Note the non-pattern matching instanceof does not produce the rawtype warning, and I don't think it should produce it.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2913


More information about the core-libs-dev mailing list