RFR: 8299505: findVirtual on array classes incorrectly restricts the receiver type [v2]

Mandy Chung mchung at openjdk.org
Wed May 31 02:53:59 UTC 2023


On Wed, 31 May 2023 01:40:22 GMT, Chen Liang <liach at openjdk.org> wrote:

>> The access hack for array class clone is only applied to `checkAccess` but missing before call to `restrictProtectedReceiver`, causing the array receiver type to be incorrectly replaced by the lookupClass type. This patch fixes that and adds a test to ensure an original lookup resolves `clone` for both array classes (public) and Object (inherited protected) correctly, and restores the old MethodHandlesGeneralTest from [JDK-8001105](https://bugs.openjdk.org/browse/JDK-8001105) which ensures correctness for publicLookup (which is already correct).
>
> 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

Looks good.

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);

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

Marked as reviewed by mchung (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/13855#pullrequestreview-1452075058
PR Review Comment: https://git.openjdk.org/jdk/pull/13855#discussion_r1210994587


More information about the core-libs-dev mailing list