On Mon, 17 Jun 2024 08:33:17 GMT, Adam Sotona <asot...@openjdk.org> wrote:

>> We need a boolean value to determine if we should proceed after replacing 
>> the appropriate "pop" instruction with an "invokedynamic" instruction. 
>> However, instead of using just a boolean field, we use a stack. The reason 
>> for this is that within the lambda expression, we can only use final 
>> variables. By using a stack, we can update its value as needed, which is why 
>> this approach is chosen.
>
> I see here an iteration over instructions of a method, where the whole class 
> is retransformed in certain situations and some status is passed back in a 
> stack of booleans.
> The whole conversion should be implemented in a single transformation.
> Original code repeatedly replaced instructions inline (that is BTW reason why 
> added nops below), however architecture of ClassFile API is different, you 
> are transforming one class into completely new class (free to remove and add 
> as many elements as you need). You can compose transformations into complex 
> trees and you can also collect information before the transformation, however 
> the class transformation should be executed only once.

Done. The code has been refactored to perform the transformation in one go.

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

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

Reply via email to