From 59e73b7a235b5f7ac86b36d1ac17a685f090a804 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Fri, 23 Dec 2022 14:52:29 +0200 Subject: [PATCH] Ensure that Kotlin subclass of QuarkusApplication works properly Fixes: #30054 --- .../deployment/steps/MainClassBuildStep.java | 35 ++++++++++++++----- .../src/main/kotlin/org/acme/MyMainClass.kt | 13 +++++++ 2 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 integration-tests/gradle/src/main/resources/basic-kotlin-application-project/src/main/kotlin/org/acme/MyMainClass.kt diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java index cfefd34f70fa4..5238f2e607e2f 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java @@ -21,6 +21,7 @@ import org.jboss.jandex.ArrayType; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; +import org.jboss.jandex.IndexView; import org.jboss.jandex.MethodInfo; import org.jboss.jandex.Type; import org.jboss.logging.Logger; @@ -102,6 +103,8 @@ public class MainClassBuildStep { void.class); public static final MethodDescriptor CONFIGURE_STEP_TIME_START = ofMethod(StepTiming.class.getName(), "configureStart", void.class); + private static final DotName QUARKUS_APPLICATION = DotName.createSimple(QuarkusApplication.class.getName()); + private static final DotName OBJECT = DotName.createSimple(Object.class.getName()); @BuildStep void build(List staticInitTasks, @@ -335,7 +338,8 @@ public MainClassBuildItem mainClassBuildStep(BuildProducer quarkusMainAnnotations = new HashMap<>(); - Collection quarkusMains = combinedIndexBuildItem.getIndex() + IndexView index = combinedIndexBuildItem.getIndex(); + Collection quarkusMains = index .getAnnotations(DotName.createSimple(QuarkusMain.class.getName())); for (AnnotationInstance i : quarkusMains) { AnnotationValue nameValue = i.value("name"); @@ -349,7 +353,7 @@ public MainClassBuildItem mainClassBuildStep(BuildProducer impls = combinedIndexBuildItem.getIndex() - .getAllKnownImplementors(DotName.createSimple(QuarkusApplication.class.getName())); - ClassInfo classByName = combinedIndexBuildItem.getIndex().getClassByName(DotName.createSimple(mainClassName)); + Collection impls = index + .getAllKnownImplementors(QUARKUS_APPLICATION); + ClassInfo classByName = index.getClassByName(DotName.createSimple(mainClassName)); MethodInfo mainClassMethod = null; if (classByName != null) { mainClassMethod = classByName @@ -401,7 +405,7 @@ public MainClassBuildItem mainClassBuildStep(BuildProducer