On Fri, 11 Jun 2021 15:15:12 GMT, Vicente Romero <vrom...@openjdk.org> wrote:

>> This PR is a copy of [PR-4416](https://github.com/openjdk/jdk/pull/4416) 
>> which was intended to openjdk/jdk.
>> 
>> Please review this PR which is syncing the implementation of 
>> `DirectMethodHandleDesc.Kind.valueOf(int)` and 
>> `DirectMethodHandleDesc.Kind.valueOf(int, boolean)` 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
>
> 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)){
> 
> @mlchung 13 hours ago Member
> 
> 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.

this is the table that is being generated right now:

Table has 20 entries
0: null
1: null
2: Kind: [name: GETTER, refKind: 1, isInterface: false]
3: Kind: [name: GETTER, refKind: 1, isInterface: false]
4: Kind: [name: STATIC_GETTER, refKind: 2, isInterface: false]
5: Kind: [name: STATIC_GETTER, refKind: 2, isInterface: false]
6: Kind: [name: SETTER, refKind: 3, isInterface: false]
7: Kind: [name: SETTER, refKind: 3, isInterface: false]
8: Kind: [name: STATIC_SETTER, refKind: 4, isInterface: false]
9: Kind: [name: STATIC_SETTER, refKind: 4, isInterface: false]
10: Kind: [name: VIRTUAL, refKind: 5, isInterface: false]
11: Kind: [name: INTERFACE_VIRTUAL, refKind: 9, isInterface: true]
12: Kind: [name: STATIC, refKind: 6, isInterface: false]
13: Kind: [name: INTERFACE_STATIC, refKind: 6, isInterface: true]
14: Kind: [name: SPECIAL, refKind: 7, isInterface: false]
15: Kind: [name: INTERFACE_SPECIAL, refKind: 7, isInterface: true]
16: Kind: [name: CONSTRUCTOR, refKind: 8, isInterface: false]
17: Kind: [name: CONSTRUCTOR, refKind: 8, isInterface: false]
18: Kind: [name: INTERFACE_VIRTUAL, refKind: 9, isInterface: true]
19: Kind: [name: INTERFACE_VIRTUAL, refKind: 9, isInterface: true]

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

PR: https://git.openjdk.java.net/jdk17/pull/29

Reply via email to