2018-01-31 16:04:56 +00:00
|
|
|
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
|
|
|
|
|
2021-08-27 08:49:31 +00:00
|
|
|
import java.util.List;
|
2021-04-12 20:19:12 +00:00
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
2018-01-31 16:04:56 +00:00
|
|
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
|
|
|
import org.objectweb.asm.tree.ClassNode;
|
|
|
|
import org.objectweb.asm.tree.FrameNode;
|
|
|
|
import org.objectweb.asm.tree.MethodNode;
|
|
|
|
import the.bytecode.club.bytecodeviewer.api.Plugin;
|
|
|
|
import the.bytecode.club.bytecodeviewer.api.PluginConsole;
|
|
|
|
|
2021-07-06 20:47:34 +00:00
|
|
|
public class StackFramesRemover extends Plugin
|
|
|
|
{
|
2018-01-31 16:04:56 +00:00
|
|
|
@Override
|
2021-08-27 08:49:31 +00:00
|
|
|
public void execute(List<ClassNode> classNodeList)
|
2021-07-06 20:47:34 +00:00
|
|
|
{
|
2018-01-31 16:04:56 +00:00
|
|
|
AtomicInteger counter = new AtomicInteger();
|
2021-07-23 22:50:18 +00:00
|
|
|
PluginConsole frame = new PluginConsole("StackFrames Remover");
|
2021-07-06 20:47:34 +00:00
|
|
|
for (ClassNode cn : classNodeList)
|
|
|
|
{
|
|
|
|
for (MethodNode mn : cn.methods)
|
|
|
|
{
|
|
|
|
for (AbstractInsnNode insn : mn.instructions.toArray())
|
|
|
|
{
|
|
|
|
if (insn instanceof FrameNode)
|
|
|
|
{
|
2018-01-31 16:04:56 +00:00
|
|
|
mn.instructions.remove(insn);
|
|
|
|
counter.incrementAndGet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
frame.appendText(String.format("Removed %s stackframes.", counter));
|
|
|
|
frame.setVisible(true);
|
|
|
|
}
|
2021-08-27 08:49:31 +00:00
|
|
|
}
|