Fixed write bytecode into file

This commit is contained in:
i22007 2024-05-08 14:07:16 +02:00
parent 4699e655fe
commit 94c037467e
2 changed files with 10 additions and 2 deletions

View File

@ -1,3 +1,3 @@
public class Example() {
public class Example {
}

View File

@ -4,6 +4,7 @@ import ast.ClassNode;
import ast.FieldNode;
import ast.MemberNode;
import ast.MethodNode;
import java.io.File;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
@ -34,7 +35,14 @@ public class ClassCodeGen {
}
private void printIntoClassFile(byte[] byteCode, String name) {
String filePath = "./classFileOutput/" + name + ".class";
String filePath = "src/main/java/classFileOutput/" + name + ".class";
String directoryPath = "src/main/java/classFileOutput";
File directory = new File(directoryPath);
if (!directory.exists()) {
directory.mkdirs();
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(filePath);