Skip to content

Commit 15232bf

Browse files
committed
Register Kotlin's empty list and map for reflection
Fixes: #44472
1 parent 90b6e9b commit 15232bf

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinProcessor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ void registerKotlinReflection(final BuildProducer<ReflectiveClassBuildItem> refl
6161
.build());
6262
reflectiveClass.produce(ReflectiveClassBuildItem.builder("kotlin.KotlinVersion$Companion[]").constructors(false)
6363
.build());
64+
reflectiveClass.produce(
65+
ReflectiveClassBuildItem.builder("kotlin.collections.EmptyList", "kotlin.collections.EmptyMap").build());
6466

6567
nativeResourcePatterns.produce(builder().includePatterns(
6668
"META-INF/.*.kotlin_module$",

integration-tests/kotlin-serialization/src/main/kotlin/io/quarkus/it/kotser/GreetingResource.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,17 @@ class GreetingResource {
7373
return Response.ok().entity(javaMethod.invoke(this)).build()
7474
}
7575

76+
@GET
77+
@Path("emptyList")
78+
fun emptyList(): List<String> {
79+
return emptyList<String>()
80+
}
81+
82+
@GET
83+
@Path("emptyMap")
84+
fun emptyMap(): Map<String, String> {
85+
return emptyMap<String, String>()
86+
}
87+
7688
fun reflect() = "hello, world"
7789
}

integration-tests/kotlin-serialization/src/test/kotlin/io/quarkus/it/kotser/ResourceTest.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,14 @@ open class ResourceTest {
124124
body(CoreMatchers.equalTo("hello, world"))
125125
}
126126
}
127+
128+
@Test
129+
fun testEmptyList() {
130+
When { get("/emptyList") } Then { statusCode(200) }
131+
}
132+
133+
@Test
134+
fun testEmptyMap() {
135+
When { get("/emptyList") } Then { statusCode(200) }
136+
}
127137
}

0 commit comments

Comments
 (0)