mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 16:09:21 +08:00
Refuse kotlin classes in ClassJsonAdapter (#749)
* Refuse kotlin classes in ClassJsonAdapter * Fail() * Tweak message
This commit is contained in:
@@ -952,4 +952,16 @@ class KotlinJsonAdapterTest {
|
||||
assertThat(adapter.fromJson("null")).isNull()
|
||||
assertThat(adapter.toJson(null)).isEqualTo("null")
|
||||
}
|
||||
|
||||
@Test fun kotlinClassesWithoutAdapterAreRefused() {
|
||||
val moshi = Moshi.Builder().build()
|
||||
try {
|
||||
moshi.adapter<PlainKotlinClass>(PlainKotlinClass::class.java)
|
||||
fail("Should not pass here")
|
||||
} catch (e: IllegalArgumentException) {
|
||||
assertThat(e).hasMessageContaining("Reflective serialization of Kotlin classes")
|
||||
}
|
||||
}
|
||||
|
||||
class PlainKotlinClass
|
||||
}
|
||||
|
Reference in New Issue
Block a user