Skip to content

Commit

Permalink
fix: Annotations being stripped from methods in assembler in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Mar 20, 2021
1 parent 7b991ef commit 11b54d3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/me/coley/recaf/util/ClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,20 @@ public static boolean isClass(byte[] data) {
* @param to method to copy to.
*/
public static void copyMethodMetadata(MethodNode from, MethodNode to) {
if (to.invisibleAnnotations == null && from.invisibleAnnotations != null)
to.invisibleAnnotations = new ArrayList<>();
if (to.visibleAnnotations == null && from.visibleAnnotations != null)
to.visibleAnnotations = new ArrayList<>();
if (to.invisibleTypeAnnotations == null && from.invisibleTypeAnnotations != null)
to.invisibleTypeAnnotations = new ArrayList<>();
if (to.visibleTypeAnnotations == null && from.visibleTypeAnnotations != null)
to.visibleTypeAnnotations = new ArrayList<>();
if (to.invisibleLocalVariableAnnotations == null && from.invisibleLocalVariableAnnotations != null)
to.invisibleLocalVariableAnnotations = new ArrayList<>();
if (to.visibleLocalVariableAnnotations == null && from.visibleLocalVariableAnnotations != null)
to.visibleLocalVariableAnnotations = new ArrayList<>();
updateAnnotationList(to.invisibleAnnotations, from.invisibleAnnotations);
updateAnnotationList(to.visibleAnnotations, from.visibleAnnotations);
updateAnnotationList(to.invisibleAnnotations, from.invisibleAnnotations);
updateAnnotationList(to.invisibleTypeAnnotations, from.invisibleTypeAnnotations);
updateAnnotationList(to.visibleTypeAnnotations, from.visibleTypeAnnotations);
updateAnnotationList(to.invisibleLocalVariableAnnotations, from.invisibleLocalVariableAnnotations);
Expand Down

0 comments on commit 11b54d3

Please # to comment.