2018-01-31 16:04:56 +00:00
|
|
|
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
|
|
|
|
|
2021-04-12 20:19:12 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
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-07-06 20:47:34 +00:00
|
|
|
public void execute(ArrayList<ClassNode> classNodeList)
|
|
|
|
{
|
2018-01-31 16:04:56 +00:00
|
|
|
AtomicInteger counter = new AtomicInteger();
|
|
|
|
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-07-06 20:47:34 +00:00
|
|
|
}
|