Fixed write bytecode into file
This commit is contained in:
parent
4699e655fe
commit
94c037467e
@ -1,3 +1,3 @@
|
|||||||
public class Example() {
|
public class Example {
|
||||||
|
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import ast.ClassNode;
|
|||||||
import ast.FieldNode;
|
import ast.FieldNode;
|
||||||
import ast.MemberNode;
|
import ast.MemberNode;
|
||||||
import ast.MethodNode;
|
import ast.MethodNode;
|
||||||
|
import java.io.File;
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
|
|
||||||
@ -34,7 +35,14 @@ public class ClassCodeGen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void printIntoClassFile(byte[] byteCode, String name) {
|
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 {
|
try {
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream(filePath);
|
FileOutputStream fileOutputStream = new FileOutputStream(filePath);
|
||||||
|
Loading…
Reference in New Issue
Block a user