Skip to content

Commit

Permalink
Fix visitMethodInsn not being called on ASM4 and older transformers
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenraven committed Mar 20, 2024
1 parent 1a5007d commit 537dde9
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.ModuleVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.RecordComponentVisitor;
import org.objectweb.asm.signature.SignatureVisitor;

Expand Down Expand Up @@ -48,12 +49,28 @@ protected Field(int api, FieldVisitor fieldVisitor) {
}

public static class Method extends MethodVisitor {
private final int originalApi;

protected Method(int api) {
super(NEWEST_ASM_VERSION);
originalApi = api;
}

protected Method(int api, MethodVisitor methodVisitor) {
super(NEWEST_ASM_VERSION, methodVisitor);
originalApi = api;
}

@Override
@SuppressWarnings("deprecation")
public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) {
if (originalApi < Opcodes.ASM5) {
visitMethodInsn(opcode & ~Opcodes.SOURCE_MASK, owner, name, descriptor);
return;
}
if (mv != null) {
mv.visitMethodInsn(opcode & ~Opcodes.SOURCE_MASK, owner, name, descriptor, isInterface);
}
}
}

Expand Down

0 comments on commit 537dde9

Please sign in to comment.