RFR: 8267421: j.l.constant.DirectMethodHandleDesc.Kind.valueOf(int) implementation doesn't conform to the spec regarding REF_invokeInterface handling [v2]
Mandy Chung
mchung at openjdk.java.net
Fri Jun 11 02:52:50 UTC 2021
On Thu, 10 Jun 2021 23:26:21 GMT, Vicente Romero <vromero at openjdk.org> wrote:
>> Please review this PR which is just syncing the implementation of DirectMethodHandleDesc.Kind.valueOf(int) with its spec. My reading of the method's spec is that if the value of the `refKind` parameter is: MethodHandleInfo.REF_invokeInterface, then DirectMethodHandleDesc.Kind.valueOf(int, boolean) should be called with a value of `true` for its second argument, currently it is invoked with `false` regardless of the value of the `refKind` parameter
>>
>> TIA
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
>
> addressing review changes
src/java.base/share/classes/java/lang/constant/DirectMethodHandleDesc.java line 143:
> 141: }
> 142: if (kind.refKind == refKind &&
> 143: (refKind != REF_invokeStatic || refKind != REF_invokeSpecial || kind.isInterface == isInterface)){
It reads to me that the static initializer tries to set up the table such that `valueOf(refKind, isInterface)` should find the proper kind to return except this:
// There is not a specific Kind for interfaces
if (kind == VIRTUAL) kind = INTERFACE_VIRTUAL;
This changes the entry for `REF_invokeVirtual` to kind `INTERFACE_VIRTUAL`. Do you know why? If this entry is set to VIRTUAL, then each refKind has two entries in the table corresponding to the correct result for `valueOf`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4416
More information about the core-libs-dev
mailing list