Commit 2fbe188c50f0b959ae103eab5c8653ea3ec65e75
1 parent
cf1835df
prevent duplicate method in generated handler when superinterfaces have identical methods
Showing
1 changed file
with
11 additions
and
3 deletions
java/common/com/mumfrey/liteloader/core/event/HandlerList.java
@@ -8,9 +8,11 @@ import java.net.URLClassLoader; | @@ -8,9 +8,11 @@ import java.net.URLClassLoader; | ||
8 | import java.util.ArrayList; | 8 | import java.util.ArrayList; |
9 | import java.util.Arrays; | 9 | import java.util.Arrays; |
10 | import java.util.Collection; | 10 | import java.util.Collection; |
11 | +import java.util.HashSet; | ||
11 | import java.util.Iterator; | 12 | import java.util.Iterator; |
12 | import java.util.LinkedList; | 13 | import java.util.LinkedList; |
13 | import java.util.List; | 14 | import java.util.List; |
15 | +import java.util.Set; | ||
14 | 16 | ||
15 | import net.minecraft.launchwrapper.IClassTransformer; | 17 | import net.minecraft.launchwrapper.IClassTransformer; |
16 | import net.minecraft.launchwrapper.Launch; | 18 | import net.minecraft.launchwrapper.Launch; |
@@ -710,7 +712,9 @@ public class HandlerList<T> extends LinkedList<T> implements FastIterableDeque<T | @@ -710,7 +712,9 @@ public class HandlerList<T> extends LinkedList<T> implements FastIterableDeque<T | ||
710 | 712 | ||
711 | this.populateClass(name, classNode); | 713 | this.populateClass(name, classNode); |
712 | this.transformMethods(name, classNode); | 714 | this.transformMethods(name, classNode); |
713 | - this.injectInterfaceMethods(classNode, this.type.getName()); | 715 | + |
716 | + Set<String> generatedMethods = new HashSet<String>(); | ||
717 | + this.injectInterfaceMethods(classNode, this.type.getName(), generatedMethods); | ||
714 | } | 718 | } |
715 | 719 | ||
716 | /** | 720 | /** |
@@ -832,9 +836,10 @@ public class HandlerList<T> extends LinkedList<T> implements FastIterableDeque<T | @@ -832,9 +836,10 @@ public class HandlerList<T> extends LinkedList<T> implements FastIterableDeque<T | ||
832 | * | 836 | * |
833 | * @param classNode | 837 | * @param classNode |
834 | * @param interfaceName | 838 | * @param interfaceName |
839 | + * @param generatedMethods | ||
835 | * @throws IOException | 840 | * @throws IOException |
836 | */ | 841 | */ |
837 | - private void injectInterfaceMethods(ClassNode classNode, String interfaceName) throws IOException | 842 | + private void injectInterfaceMethods(ClassNode classNode, String interfaceName, Set<String> generatedMethods) throws IOException |
838 | { | 843 | { |
839 | ClassReader interfaceReader = new ClassReader(HandlerListClassLoader.getInterfaceBytes(interfaceName)); | 844 | ClassReader interfaceReader = new ClassReader(HandlerListClassLoader.getInterfaceBytes(interfaceName)); |
840 | ClassNode interfaceNode = new ClassNode(); | 845 | ClassNode interfaceNode = new ClassNode(); |
@@ -842,13 +847,16 @@ public class HandlerList<T> extends LinkedList<T> implements FastIterableDeque<T | @@ -842,13 +847,16 @@ public class HandlerList<T> extends LinkedList<T> implements FastIterableDeque<T | ||
842 | 847 | ||
843 | for (MethodNode interfaceMethod : interfaceNode.methods) | 848 | for (MethodNode interfaceMethod : interfaceNode.methods) |
844 | { | 849 | { |
850 | + String signature = interfaceMethod.name + interfaceMethod.desc; | ||
851 | + if (generatedMethods.contains(signature)) continue; | ||
852 | + generatedMethods.add(signature); | ||
845 | classNode.methods.add(interfaceMethod); | 853 | classNode.methods.add(interfaceMethod); |
846 | this.populateInterfaceMethod(classNode, interfaceMethod); | 854 | this.populateInterfaceMethod(classNode, interfaceMethod); |
847 | } | 855 | } |
848 | 856 | ||
849 | for (String parentInterface : interfaceNode.interfaces) | 857 | for (String parentInterface : interfaceNode.interfaces) |
850 | { | 858 | { |
851 | - this.injectInterfaceMethods(classNode, parentInterface.replace('/', '.')); | 859 | + this.injectInterfaceMethods(classNode, parentInterface.replace('/', '.'), generatedMethods); |
852 | } | 860 | } |
853 | } | 861 | } |
854 | 862 |