Don't append new class files, overwrite them

This commit is contained in:
Victorious3 2023-01-31 13:49:19 +01:00
parent 0c9612a2ea
commit a7720fbf20
2 changed files with 4 additions and 4 deletions

View File

@ -979,7 +979,7 @@ public class Codegen {
}
private void generateConstructor(TargetConstructor constructor) {
MethodVisitor mv = cw.visitMethod(constructor.access() | ACC_PUBLIC, "<init>", constructor.getDescriptor(), constructor.getSignature(), null);
MethodVisitor mv = cw.visitMethod(constructor.access() | ACC_PUBLIC, "<init>", constructor.getDescriptor(), null, null);
mv.visitCode();
var state = new State(null, mv, 1);
for (var param: constructor.parameters())
@ -1027,8 +1027,8 @@ public class Codegen {
}
public byte[] generate() {
cw.visit(V1_8, clazz.modifiers() | ACC_PUBLIC, clazz.qualifiedName(),
generateSignature(clazz), clazz.superType() != null ? clazz.superType().getInternalName(): "java/lang/Object",
cw.visit(V1_8, clazz.modifiers() | ACC_PUBLIC | ACC_SUPER, clazz.qualifiedName(),
null, clazz.superType() != null ? clazz.superType().getInternalName(): "java/lang/Object",
clazz.implementingInterfaces().stream().map(TargetType::toSignature).toArray(String[]::new)
);
clazz.fields().forEach(this::generateField);

View File

@ -909,7 +909,7 @@ public class JavaTXCompiler {
// "/testBytecode/generatedBC/" +name+".class"));
File outputFile = new File(path, name.getClassName() + ".class");
outputFile.getAbsoluteFile().getParentFile().mkdirs();
output = new FileOutputStream(outputFile);
output = new FileOutputStream(outputFile, false);
output.write(bytecode);
output.close();
System.out.println(name + ".class file generated");