RFR: 8350617: Improve MethodHandles.tableSwitch and remove intrinsicData

Chen Liang liach at openjdk.org
Tue Mar 4 14:32:57 UTC 2025


On Tue, 4 Mar 2025 14:11:28 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 7664:
>> 
>>> 7662:             if (mh.type() != expectedType)
>>> 7663:                 throw new IllegalArgumentException(
>>> 7664:                     "Some targets do not have the expected type " + expectedType + ": " + caseActions);
>> 
>> I think we should avoid changing the exception messages here, since it's observable from the outside.
>> 
>> FWIW, one of the downsides of only printing out a single method handle, is that a user can't tell which method handle in the list was problematic.
>
> At least, please motivate these changes. Why do you think changing the message is needed?

Here you are making the check against the default case. However, these messages never print the default case's type, making this error message uninformative.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23763#discussion_r1979575675


More information about the core-libs-dev mailing list