RFR: 8307818: Convert Indify tool to Classfile API [v16]

Adam Sotona asotona at openjdk.org
Tue Jun 25 13:20:18 UTC 2024


On Sat, 22 Jun 2024 15:55:28 GMT, Oussama Louati <duke at openjdk.org> wrote:

>> An indify tool in j.l.i tests (also in vmTestBase) convert some source-code private static methods with MT_ MH_, and INDY_ prefixes into MethodHandle, MethodType, and CallSite constants.
>> ### Purpose of Indify
>> 
>> -  **Transformation Tool**: `Indify` transforms existing class files to leverage `invokedynamic` and other JSR 292 features. This transformation allows for dynamic method calls.
>> 
>> ### Key Functions
>> 
>> - **Method Handle and Method Type Constants**:
>>     - **MH_x and MT_x Methods**: These methods are used to generate `MethodHandle` and `MethodType` constants. The tool transforms calls to these methods into `CONSTANT_MethodHandle` and `CONSTANT_MethodType` "ldc" (load constant) instructions.
>> -  **Invokedynamic Call Sites**:
>>     - **INDY_x Methods**: These methods generate `invokedynamic` call sites. Each `INDY_x` method starts with a call to an `MH_x` method, which acts as the bootstrap method. This is followed by an `invokeExact` call.
>>     - **Transformation**: The tool transforms pairs of calls (to `INDY_x` followed by `invokeExact`) into `invokedynamic` instructions. This mimics the JVM's handling of `invokedynamic` instructions, creating dynamic call sites that are linked at runtime.
>> 
>> It currently uses ad-hoc code to process class files and intends to migrate to ASM; but since we have the Classfile API, we can migrate to Classfile API instead.
>
> Oussama Louati has updated the pull request incrementally with one additional commit since the last revision:
> 
>   remove: removed unnecessary logging

test/jdk/java/lang/invoke/indify/Indify.java line 386:

> 384: 
> 385:     byte[] transformToBytes(ClassModel classModel) {
> 386:         return of().transform(classModel, ClassTransform.ACCEPT_ALL);

What is the purpose of this transformation?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18841#discussion_r1652808158


More information about the core-libs-dev mailing list