Skip to content

Commit

Permalink
Mark generated no-args constructors as synthetic
Browse files Browse the repository at this point in the history
This is useful for code coverage tools

Relates to: quarkusio#24404 (comment)
  • Loading branch information
geoand committed Jan 28, 2023
1 parent 24bae58 commit b564222
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ public ClassVisitor apply(String className, ClassVisitor classVisitor) {
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
super.visit(version, access, name, signature, superName, interfaces);
MethodVisitor ctor = visitMethod(Modifier.PUBLIC, "<init>", "()V", null,
MethodVisitor ctor = visitMethod(Modifier.PUBLIC | Opcodes.ACC_SYNTHETIC, "<init>", "()V",
null,
null);
ctor.visitCode();
ctor.visitVarInsn(Opcodes.ALOAD, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ public void visit(int version, int access, String name, String signature,
String superName,
String[] interfaces) {
super.visit(version, access, name, signature, superName, interfaces);
MethodVisitor mv = visitMethod(Modifier.PUBLIC, Methods.INIT, "()V", null,
MethodVisitor mv = visitMethod(Modifier.PUBLIC | Opcodes.ACC_SYNTHETIC, Methods.INIT, "()V", null,
null);
mv.visitCode();
mv.visitVarInsn(Opcodes.ALOAD, 0);
Expand Down

0 comments on commit b564222

Please sign in to comment.