1919
2020package com .cleanroommc .modularui .core .temp ;
2121
22- import java .io .IOException ;
23- import java .io .InputStream ;
24- import java .util .List ;
25- import java .util .ListIterator ;
26- import java .util .Set ;
27- import java .util .function .Consumer ;
28-
2922import com .cleanroommc .modularui .core .ModularUICore ;
3023
3124import com .google .common .collect .Lists ;
4235import org .objectweb .asm .tree .MethodInsnNode ;
4336import org .objectweb .asm .tree .MethodNode ;
4437
38+ import java .io .IOException ;
39+ import java .io .InputStream ;
40+ import java .util .List ;
41+ import java .util .ListIterator ;
42+ import java .util .Set ;
43+ import java .util .function .Consumer ;
44+
45+ /**
46+ * This class only exists for compatibility with AE2. Remove once
47+ * <a href="https://github.com/AE2-UEL/Applied-Energistics-2/pull/572">AE2-UEL#572</a> is merged.
48+ */
49+ @ Deprecated
4550public class ClassSplicer {
51+
4652 public static byte [] processNode (byte [] data , Consumer <ClassNode > classNodeConsumer ) {
4753 ClassReader reader = new ClassReader (data );
4854 ClassNode nodeOrig = new ClassNode ();
@@ -61,7 +67,6 @@ public static void spliceClasses(final ClassNode data, final String className, f
6167 }
6268 }
6369
64-
6570 public static void spliceClasses (final ClassNode nodeData , final byte [] dataSplice , final String className , final String ... methods ) {
6671 // System.out.println("Splicing from " + className + " to " + targetClassName)
6772 if (dataSplice == null ) {
@@ -96,18 +101,15 @@ public String map(final String name) {
96101 boolean added = false ;
97102
98103 for (int j = 0 ; j < nodeData .methods .size (); j ++) {
99- if (nodeData .methods .get (j ).name .equals (mn .name )
100- && nodeData .methods .get (j ).desc .equals (mn .desc )) {
104+ if (nodeData .methods .get (j ).name .equals (mn .name ) && nodeData .methods .get (j ).desc .equals (mn .desc )) {
101105 MethodNode oldMn = nodeData .methods .get (j );
102106 System .out .println ("Spliced in METHOD: " + targetClassName + "." + mn .name );
103107 nodeData .methods .set (j , mn );
104108 if (nodeData .name .equals (nodeSplice .superName )) {
105109 ListIterator <AbstractInsnNode > nodeListIterator = mn .instructions .iterator ();
106110 while (nodeListIterator .hasNext ()) {
107111 AbstractInsnNode node = nodeListIterator .next ();
108- if (node instanceof MethodInsnNode
109- && node .getOpcode () == Opcodes .INVOKESPECIAL ) {
110- MethodInsnNode methodNode = (MethodInsnNode ) node ;
112+ if (node instanceof MethodInsnNode methodNode && node .getOpcode () == Opcodes .INVOKESPECIAL ) {
111113 if (targetClassName2 .equals (methodNode .owner )) {
112114 methodNode .owner = nodeData .superName ;
113115 }
@@ -152,6 +154,5 @@ public String map(final String name) {
152154 }
153155 }
154156 }
155-
156157 }
157158}
0 commit comments