On Fri, 4 Jun 2021 01:22:05 GMT, liach <github.com+7806504+li...@openjdk.org> 
wrote:

>> Dan Smith has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Fix accidentally commented-out parts of test
>
> src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java line 547:
> 
>> 545:             throw new IllegalArgumentException("argument has wrong 
>> type");
>> 546:         }
>> 547:         return type.cast(result);
> 
> Can we just use a `return (T) result` as there will always be a checked cast 
> on the caller's end, and this call seems redundant? The only shortcoming is 
> that the call will raise an unchecked warning that needs to be suppressed. Or 
> is this negligible after hotspot optimization?

Eh, the scale here is quite small (never more than, say, 20 items), and an 
instanceof + a cast is a routine coding style that I'd expect to be optimized 
away. Doesn't seem worth the maintenance noise of a `@SuppressWarnings`.

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

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

Reply via email to