RFR: 8187655: jdk.lambda.vm.InterfaceAccessFlagsTest.testPrivateMethodCall needs update after nestmates support

Mandy Chung mchung at openjdk.org
Tue Nov 7 03:22:28 UTC 2023


On Tue, 7 Nov 2023 02:30:55 GMT, Chen Liang <liach 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.
>
> test/jdk/jdk/lambda/separate/ClassToInterfaceConverter.java line 43:
> 
>> 41:                     for (ClassElement ce : classModel) {
>> 42:                         if (ce instanceof AccessFlags accessFlags) {
>> 43:                             classBuilder.withFlags(0x0601); // ACC_INTERFACE | ACC_ABSTRACT | ACC_PUBLIC);
> 
> We can just use `withFlags(Classfile.ACC_INTERFACE | Classfile.ACC_ABSTRACT | Classfile.ACC_PUBLIC)` as it's a constant expression and inlined by javac. And the `accessFlags` variable above appears unused.

I have same thought too.  I have that changed in my local repo but not have the chance to push it.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16526#discussion_r1384326189


More information about the core-libs-dev mailing list