On Thu, 15 Jan 2026 21:54:40 GMT, Andy Goryachev <[email protected]> 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
