diff --git a/src/main/java/CompilerInput.txt b/src/main/java/CompilerInput.txt index 75d8cd9..106dace 100644 --- a/src/main/java/CompilerInput.txt +++ b/src/main/java/CompilerInput.txt @@ -1,3 +1,3 @@ -public class Example() { +public class Example { } \ No newline at end of file diff --git a/src/main/java/bytecode/ClassCodeGen.java b/src/main/java/bytecode/ClassCodeGen.java index a59a632..e9eb641 100644 --- a/src/main/java/bytecode/ClassCodeGen.java +++ b/src/main/java/bytecode/ClassCodeGen.java @@ -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);