LibJF/libjf-legacy-v0/src/main/java/io/gitlab/jfronny/libjf/legacy/LegacyPatcher.java

33 lines
1.1 KiB
Java

package io.gitlab.jfronny.libjf.legacy;
import io.gitlab.jfronny.libjf.unsafe.asm.AsmConfig;
import io.gitlab.jfronny.libjf.unsafe.asm.patch.Patch;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import java.util.Set;
public class LegacyPatcher implements AsmConfig {
@Override
public Set<String> skipClasses() {
return Set.of();
}
@Override
public Set<Patch> getPatches() {
return Set.of(klazz -> {
if (!klazz.name.startsWith("io/gitlab/jfronny/")) return;
for (MethodNode method : klazz.methods) {
for (AbstractInsnNode insn : method.instructions) {
if (!(insn instanceof MethodInsnNode node)) continue;
if (!node.owner.equals("io/gitlab/jfronny/commons/log/Logger")) continue;
node.itf = false;
if (node.getOpcode() == Opcodes.INVOKEINTERFACE) node.setOpcode(Opcodes.INVOKEVIRTUAL);
}
}
});
}
}