46 lines
1.2 KiB
Java
46 lines
1.2 KiB
Java
import dev.w1zzrd.asm.Combine;
|
|
import dev.w1zzrd.asm.GraftSource;
|
|
import dev.w1zzrd.asm.Merger;
|
|
import jdk.internal.org.objectweb.asm.tree.ClassNode;
|
|
import jdk.internal.org.objectweb.asm.tree.MethodNode;
|
|
|
|
import java.io.IOException;
|
|
|
|
public class Test {
|
|
public static void main(String... args) throws IOException {
|
|
|
|
ClassNode target = Merger.getClassNode("MergeTest");
|
|
ClassNode inject = Merger.getClassNode("MergeInject");
|
|
GraftSource source = new GraftSource(target);
|
|
|
|
Combine combine = new Combine(target);
|
|
for (MethodNode method : source.getInjectMethods()) {
|
|
combine.inject(method, source);
|
|
}
|
|
|
|
combine.compile();
|
|
|
|
System.out.println("Asdf");
|
|
|
|
/*
|
|
Merger m = new Merger("MergeTest");
|
|
m.inject("MergeInject");
|
|
|
|
// Save injected data
|
|
File f = new File("out.class");
|
|
if(f.isFile() && f.delete() && f.createNewFile()) {
|
|
FileOutputStream fos = new FileOutputStream(f);
|
|
fos.write(m.toByteArray());
|
|
fos.close();
|
|
}
|
|
|
|
// Compile and run
|
|
m.compile();
|
|
|
|
Runnable r = (Runnable)new MergeTest("Constructor message");
|
|
r.run();
|
|
*/
|
|
}
|
|
|
|
}
|