From a1378f1cfba08f12df42feb904db546f41cb79e7 Mon Sep 17 00:00:00 2001 From: i22007 Date: Wed, 8 May 2024 10:35:18 +0200 Subject: [PATCH] Add constructor for empty class --- src/main/java/bytecode/ByteCodeGenerator.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/bytecode/ByteCodeGenerator.java b/src/main/java/bytecode/ByteCodeGenerator.java index 8b07bbb..b69b823 100644 --- a/src/main/java/bytecode/ByteCodeGenerator.java +++ b/src/main/java/bytecode/ByteCodeGenerator.java @@ -3,6 +3,7 @@ package bytecode; import java.io.FileOutputStream; import java.io.IOException; import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import parser.ClassDeclarationNode; import parser.ProgramNode; @@ -14,7 +15,15 @@ public class ByteCodeGenerator { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, classDeclarationNode.identifier, null, "java/lang/Object", null); + + MethodVisitor constructor = + cw.visitMethod(Opcodes.ACC_PUBLIC, + "", + "()V", + null, + null); cw.visitEnd(); + printIntoClassFile(cw.toByteArray(), classDeclarationNode.identifier); } }