From ea60f37957187480b54d059b8018744a668f849d Mon Sep 17 00:00:00 2001 From: Ashhhleyyy Date: Fri, 19 Apr 2024 14:44:29 +0100 Subject: [PATCH] feat: add classinspector for looking inside class files interactively (using a debugger) --- .../dev/ashhhleyyy/bad/ClassInspector.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/dev/ashhhleyyy/bad/ClassInspector.java diff --git a/src/main/java/dev/ashhhleyyy/bad/ClassInspector.java b/src/main/java/dev/ashhhleyyy/bad/ClassInspector.java new file mode 100644 index 0000000..f6f85e1 --- /dev/null +++ b/src/main/java/dev/ashhhleyyy/bad/ClassInspector.java @@ -0,0 +1,24 @@ +package dev.ashhhleyyy.bad; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.ClassNode; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +public class ClassInspector { + public static void main(String[] args) throws IOException { + if (args.length < 1) { + System.err.println("Usage: "); + System.exit(1); + } + String path = args[0]; + byte[] data = Files.readAllBytes(Path.of(path)); + ClassReader reader = new ClassReader(data); + ClassNode cls = new ClassNode(Opcodes.ASM9); + reader.accept(cls, 0); + System.out.println("Set breakpoint here."); + } +}