RFR: 8375016: Several catch blocks for NullPointerExceptions exist in the codebase [v5]
Christopher Schnick
duke at openjdk.org
Thu Jan 15 22:30:30 UTC 2026
On Thu, 15 Jan 2026 21:54:40 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> Ah, I think I know what you mean now.
>>
>> Since this is about the handling of generics, the original catch block should never be reached in my understanding. The generic T type is erased, meaning this method should always return the value, regardless of whether the type matches or not.
>>
>> If you do assign the return value of this method to a String, and the returned value is not of type string, it will always throw a ClassCastException. But that should also happen for the old method with the catch block as well. The exception happens outside the method, that is the important part
>
> my point this is not an equivalent change, because it changes the behavior. Before the change, a null will be returned, after this change - a non-null value of some other class.
>
> we don't want to change the scope of this PR, right?
I added a test that should clarify the handling for mismatched types. The test passes both in the old and new implementation to show that the behaviour is the same and in both cases, null is never returned on mismatched types
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2032#discussion_r2696187250
More information about the openjfx-dev
mailing list