Skip to content

Commit

Permalink
Panache: do not create findById bridge for abstract entity repositories
Browse files Browse the repository at this point in the history
If the entity type is not fixed in the hierarchy yet, don't generate the bridge

Fix quarkusio#5274
  • Loading branch information
FroMage committed Nov 7, 2019
1 parent 37bdc97 commit d2a645d
Showing 1 changed file with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,26 @@ protected String getPanacheOperationsBinaryName() {

@Override
public void visitEnd() {
// Bridge for findById
MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE,
"findById",
"(Ljava/lang/Object;)Ljava/lang/Object;",
null,
null);
mv.visitParameter("id", 0);
mv.visitCode();
mv.visitIntInsn(Opcodes.ALOAD, 0);
mv.visitIntInsn(Opcodes.ALOAD, 1);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
daoBinaryName,
"findById",
"(Ljava/lang/Object;)" + entitySignature, false);
mv.visitInsn(Opcodes.ARETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();

// Bridge for findById, but only if we actually know the end entity (which we don't for intermediate
// abstract repositories that haven't fixed their entity type yet
if (!"Ljava/lang/Object;".equals(entitySignature)) {
MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE,
"findById",
"(Ljava/lang/Object;)Ljava/lang/Object;",
null,
null);
mv.visitParameter("id", 0);
mv.visitCode();
mv.visitIntInsn(Opcodes.ALOAD, 0);
mv.visitIntInsn(Opcodes.ALOAD, 1);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
daoBinaryName,
"findById",
"(Ljava/lang/Object;)" + entitySignature, false);
mv.visitInsn(Opcodes.ARETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
super.visitEnd();
}

Expand Down

0 comments on commit d2a645d

Please sign in to comment.