RFR: 8187655: jdk.lambda.vm.InterfaceAccessFlagsTest.testPrivateMethodCall needs update after nestmates support [v2]
Chen Liang
liach at openjdk.org
Wed Nov 8 00:34:00 UTC 2023
On Tue, 7 Nov 2023 18:34:42 GMT, Mandy Chung <mchung at openjdk.org> wrote:
>> `jdk.lambda.vm.InterfaceAccessFlagsTest` uses `ClassToInterfaceConverter` to mechanically convert a classfile for a Class into an in-memory class representation of an equivalent Interface. `testPrivateMethodCall` tests to invoke a private method. Before nestmates, invoking a private class method and a private interface method both use `Invokespecial`. With the nestmate changes, the class uses `invokevirtual` but the interface must use `invokeinterface` but this conversion is not handled by the existing `ClassToInterfaceConverter`.
>>
>> This fix converts `ClassToInterfaceConverter` to use the Class-File API to properly convert a classfile from a class to an interface including method invocation from `invokevirtual` to `invokeinterface`. The old custom bytecode manipulation code can be dropped.
>
> Mandy Chung has updated the pull request incrementally with one additional commit since the last revision:
>
> Simplify the transformation code and easier to read
test/jdk/jdk/lambda/separate/ClassToInterfaceConverter.java line 43:
> 41: // convert it to invokeinterface
> 42: CodeTransform ct = (b, e) -> {
> 43: if (e instanceof InvokeInstruction i && i.owner() == classModel.thisClass()) {
Suggestion:
if (e instanceof InvokeInstruction i && i.owner().equals(classModel.thisClass())) {
`ClassDesc` has to be compared by equality. This piece of code works accidentally due to Classfile API caching descriptor in CP objects, but if the `ClassDesc` is from a `DynamicConstantDesc`, then it breaks.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16526#discussion_r1385794688
More information about the core-libs-dev
mailing list