diff --git a/pom.xml b/pom.xml index d0d95d138..12752da6c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ me.coley recaf https://github.com/Col-E/Recaf/ - 2.19.0 + 2.19.1 Recaf A modern java bytecode editor diff --git a/src/main/java/me/coley/recaf/Recaf.java b/src/main/java/me/coley/recaf/Recaf.java index cab849430..fdc6e7dbe 100644 --- a/src/main/java/me/coley/recaf/Recaf.java +++ b/src/main/java/me/coley/recaf/Recaf.java @@ -31,7 +31,7 @@ * @author Matt */ public class Recaf { - public static final String VERSION = "2.19.0"; + public static final String VERSION = "2.19.1"; public static final String DOC_URL = "https://col-e.github.io/Recaf-documentation/"; public static final int ASM_VERSION = Opcodes.ASM9; private static Controller currentController; diff --git a/src/main/java/me/coley/recaf/util/ClassUtil.java b/src/main/java/me/coley/recaf/util/ClassUtil.java index 770ebd7cd..c55327996 100644 --- a/src/main/java/me/coley/recaf/util/ClassUtil.java +++ b/src/main/java/me/coley/recaf/util/ClassUtil.java @@ -3,9 +3,7 @@ import me.coley.recaf.Recaf; import me.coley.recaf.util.struct.Pair; import org.objectweb.asm.*; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; -import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.*; import java.io.IOException; import java.util.ArrayList; @@ -340,13 +338,37 @@ public static void copyMethodMetadata(MethodNode from, MethodNode to) { } @SuppressWarnings("all") - private static void updateAnnotationList(List to, List from) { + private static void updateAnnotationList(List to, List from) { // No data to copy if (from == null) return; // Add if not null if (to != null) - to.addAll(from); + for (T node : from) { + String fromType = node.desc; + // We are replacing the annotation of the matching type. + // You can only have one of any single type on an item. + if (node instanceof TypeAnnotationNode) { + // For type annotations we need to do some extra checks... + to.removeIf(n -> { + if (!n.desc.equals(fromType)) { + return false; + } + if (n instanceof TypeAnnotationNode) { + TypeAnnotationNode fromNode = (TypeAnnotationNode) node; + TypeAnnotationNode toNode = (TypeAnnotationNode) n; + // Type paths must match as well, indicating the target is the same + return fromNode.typePath.toString().equals(toNode.typePath.toString()); + } + return false; + }); + } else { + to.removeIf(n -> n.desc.equals(fromType)); + } + + to.add(node); + } + } /**