Skip to content

Commit

Permalink
Ensure that Kotlin implementation of QuarkusApplication works properly
Browse files Browse the repository at this point in the history
Fixes: quarkusio#30190

Follows up on: quarkusio#30058 (which incorrectly checked for QuarkusApplication
as a superclass)
  • Loading branch information
geoand committed Jan 5, 2023
1 parent 5837733 commit eb4229d
Showing 1 changed file with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,25 +419,15 @@ public MainClassBuildItem mainClassBuildStep(BuildProducer<GeneratedClassBuildIt
}

private static String sanitizeMainClassName(ClassInfo mainClass, IndexView index) {
String className = mainClass.name().toString();
DotName mainClassDotName = mainClass.name();
String className = mainClassDotName.toString();
if (isKotlinClass(mainClass)) {
MethodInfo mainMethod = mainClass.method("main",
ArrayType.create(Type.create(DotName.createSimple(String.class.getName()), Type.Kind.CLASS), 1));
if (mainMethod == null) {
ClassInfo classToCheck = mainClass;
boolean hasQuarkusApplicationSuperClass = false;
while (classToCheck != null) {
DotName superName = classToCheck.superName();
if (superName.equals(QUARKUS_APPLICATION)) {
hasQuarkusApplicationSuperClass = true;
break;
}
if (superName.equals(OBJECT)) {
break;
}
classToCheck = index.getClassByName(superName);
}
if (!hasQuarkusApplicationSuperClass) {
boolean hasQuarkusApplicationInterface = index.getAllKnownImplementors(QUARKUS_APPLICATION).stream().map(
ClassInfo::name).anyMatch(d -> d.equals(mainClassDotName));
if (!hasQuarkusApplicationInterface) {
className += "Kt";
}
}
Expand Down

0 comments on commit eb4229d

Please sign in to comment.