Compare commits

..

3 commits

Author SHA1 Message Date
ea60f37957
feat: add classinspector for looking inside class files interactively (using a debugger)
All checks were successful
Maven release / build (push) Successful in 2m0s
2024-04-19 14:44:29 +01:00
bbbd60ce0a
feat: add invokedynamic to BytecodeBuilder 2024-04-19 14:44:04 +01:00
9eaafb50fb
chore: random intellij files 2024-04-19 14:43:21 +01:00
5 changed files with 38 additions and 15 deletions

1
.idea/.name Normal file
View file

@ -0,0 +1 @@
bf

View file

@ -4,7 +4,7 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

6
.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -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: <class>");
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.");
}
}

View file

@ -3,22 +3,10 @@ package dev.ashhhleyyy.bad.framework;
import java.util.HashMap;
import java.util.Map;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Label;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.IincInsnNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.IntInsnNode;
import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.LocalVariableNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.VarInsnNode;
import org.objectweb.asm.tree.*;
public final class BytecodeBuilder {
private final ClassNode classNode;
@ -163,6 +151,10 @@ public final class BytecodeBuilder {
this.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, name, desc));
}
public void invokedynamic(String name, String descriptor, Handle bsm, Object... bsmArgs) {
this.add(new InvokeDynamicInsnNode(name, descriptor, bsm, bsmArgs));
}
private LabelNode getCurrentLabel() {
if (this.currentLabel != null) {
return this.currentLabel;