diff --git a/extensions/panache/panache-common/deployment/src/main/java/io/quarkus/panache/common/deployment/visitors/KotlinPanacheClassOperationGenerationVisitor.java b/extensions/panache/panache-common/deployment/src/main/java/io/quarkus/panache/common/deployment/visitors/KotlinPanacheClassOperationGenerationVisitor.java index c1cdd463b82a2e..c2f035b45aeaf1 100644 --- a/extensions/panache/panache-common/deployment/src/main/java/io/quarkus/panache/common/deployment/visitors/KotlinPanacheClassOperationGenerationVisitor.java +++ b/extensions/panache/panache-common/deployment/src/main/java/io/quarkus/panache/common/deployment/visitors/KotlinPanacheClassOperationGenerationVisitor.java @@ -64,6 +64,7 @@ public class KotlinPanacheClassOperationGenerationVisitor extends ClassVisitor { public static final String NULLABLE_DESCRIPTOR = "Lorg/jetbrains/annotations/Nullable;"; public static final ByteCodeType OBJECT = new ByteCodeType(Object.class); protected static final ByteCodeType CLASS = new ByteCodeType(Class.class); + private static final String CTOR_METHOD_NAME = ""; protected final Function argMapper; protected final ClassInfo classInfo; protected final ByteCodeType entityUpperBound; @@ -291,7 +292,7 @@ private void emitNullCheck(MethodVisitor mv, Type returnType) { .replace("java.util.List", "kotlin.collections.List"))); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/NullPointerException", - "", "(Ljava/lang/String;)V", false); + CTOR_METHOD_NAME, "(Ljava/lang/String;)V", false); mv.visitInsn(ATHROW); mv.visitLabel(label); mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] { "java/lang/Object" }); @@ -538,6 +539,9 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str } else if (name.contains("$")) { //some agents such as jacoco add new methods, they generally have $ in the name return super.visitMethod(access, name, descriptor, signature, exceptions); + } else if (name.equals(CTOR_METHOD_NAME)) { + //Arc can add no-args constructors to support intercepted beans + return super.visitMethod(access, name, descriptor, signature, exceptions); } return null; } diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AddressDao.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AddressDao.kt index 31932718646331..f10ac5da7b6e5e 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AddressDao.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AddressDao.kt @@ -4,7 +4,7 @@ import io.quarkus.hibernate.orm.panache.kotlin.PanacheRepositoryBase import javax.enterprise.context.ApplicationScoped @ApplicationScoped -open class AddressDao : PanacheRepositoryBase { +open class AddressDao(private val dummyService: DummyService) : PanacheRepositoryBase { companion object { fun shouldBeOverridden(): Nothing { throw UnsupportedOperationException("this should be called and not be overwritten by the quarkus plugin") @@ -12,4 +12,4 @@ open class AddressDao : PanacheRepositoryBase { } override fun count(query: String, params: Map): Long = shouldBeOverridden() -} \ No newline at end of file +} diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/DummyService.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/DummyService.kt new file mode 100644 index 00000000000000..85c330413fdb75 --- /dev/null +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/DummyService.kt @@ -0,0 +1,8 @@ +package io.quarkus.it.panache.kotlin + +import javax.enterprise.context.ApplicationScoped + +// used only to validate that we can inject CDI beans into Panache repositories written in Kotlin +@ApplicationScoped +class DummyService { +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookRepository.kt index c2d2bebd4c4e63..30e6438eac573e 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookRepository.kt @@ -4,4 +4,4 @@ import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepository import javax.enterprise.context.ApplicationScoped @ApplicationScoped -class BookRepository : PanacheMongoRepository \ No newline at end of file +class BookRepository(private val dummyService: DummyService) : PanacheMongoRepository diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/DummyService.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/DummyService.kt new file mode 100644 index 00000000000000..eed33d52a1ba8a --- /dev/null +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/DummyService.kt @@ -0,0 +1,8 @@ +package io.quarkus.it.mongodb.panache.book + +import javax.enterprise.context.ApplicationScoped + +// used only to validate that we can inject CDI beans into Panache repositories written in Kotlin +@ApplicationScoped +class DummyService { +}