RFR: 8299505: findVirtual on array classes incorrectly restricts the receiver type [v2]
Chen Liang
liach at openjdk.org
Wed May 31 03:45:59 UTC 2023
On Wed, 31 May 2023 01:42:17 GMT, Mandy Chung <mchung at openjdk.org> wrote:
>> Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>>
>> - Update per review
>> - Merge branch 'master' into fix/lookup-array-clone
>> - 8299505: findVirtual on array classes incorrectly restricts the receiver type
>
> test/jdk/java/lang/invoke/findVirtual/FindVirtualArrayCloneTest.java line 70:
>
>> 68: var cloneMh = MethodHandles.lookup()
>> 69: .findVirtual(String[].class, "clone", MethodType.methodType(Object.class));
>> 70: var mhClone = (String[]) (Object) cloneMh.invokeExact((String[]) array);
>
> Suggestion:
>
> var mhClone = (String[]) cloneMh.invokeExact((String[]) array);
the clone Method handle will have a type of `(String[])Object`, as `findVirtual` for `clone` uses the Object return method type, and there is no covariant override in array classes (which don't declare any methods)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13855#discussion_r1211053514
More information about the core-libs-dev
mailing list