Fix wrong descriptor in ASMEventExecutorGenerator (#8506)

This commit is contained in:
Hannes Greule 2022-10-28 02:27:33 +02:00
parent 40889ab866
commit 878600ebbc

View file

@ -136,6 +136,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import static org.objectweb.asm.Opcodes.*;
+
+public class ASMEventExecutorGenerator {
+
+ private static final String EXECUTE_DESCRIPTOR = "(Lorg/bukkit/event/Listener;Lorg/bukkit/event/Event;)V";
+
+ @NotNull
+ public static byte[] generateEventExecutor(@NotNull Method m, @NotNull String name) {
+ ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
@ -147,7 +150,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ methodGenerator.returnValue();
+ methodGenerator.endMethod();
+ // Generate the execute method
+ methodGenerator = new GeneratorAdapter(writer.visitMethod(ACC_PUBLIC, "execute", "(Lorg/bukkit/event/Listener;Lorg/bukkit/event/Event;)V", null, null), ACC_PUBLIC, "execute", "(Lorg/bukkit/event/Listener;Lorg/bukkit/event/Listener;)V");
+ methodGenerator = new GeneratorAdapter(writer.visitMethod(ACC_PUBLIC, "execute", EXECUTE_DESCRIPTOR, null, null), ACC_PUBLIC, "execute", EXECUTE_DESCRIPTOR);
+ methodGenerator.loadArg(0);
+ methodGenerator.checkCast(Type.getType(m.getDeclaringClass()));
+ methodGenerator.loadArg(1);