kotlin-reflect Questions
2
Why calling method toString() on function reference results in an error KotlinReflectionInternalError
fun main() {
fun foo(){}
::foo.toString()
}
output:
Exception in thread "main" kot...
Woundwort asked 18/11, 2022 at 8:54
3
I have a multi-module project. With the same build, the apk's size may differ by 300KB (from 17 to 17.3MB). In the build with 17MB in runtime I get an error:
java.lang.AssertionError: Built-in cla...
Dupondius asked 8/11, 2019 at 13:31
2
I can access a private val value using reflection as below
fun main() {
val mainClass = MainClass()
val f = MainClass::class.memberProperties.find { it.name == "info" }
f?.let {
it.isAccessibl...
Simulation asked 13/10, 2019 at 5:33
3
Solved
In the example below, t::x returns a reference to a property getter. How do I obtain the same for a setter?
class Test(var x: String) {}
fun main(args: Array<String>) {
val t = Test("A")
...
Waikiki asked 18/3, 2017 at 12:4
1
Solved
I have a package with some data classes and I'm trying to access the constructor at runtime using Kotlin reflection clazz.primaryConstructor,
Everything is working as expected but when I enable R8,...
Uchida asked 11/12, 2021 at 12:42
2
Let's say I have this class
data class Person(val name: String?)
When I proguard and run the app I am getting the following exception
kotlin.reflect.jvm.internal.KotlinReflectionInternalError: ...
Barty asked 31/1, 2019 at 12:15
4
Solved
Is it possiable to use reflection to access a object's private field and call a public methods on this field?
i.e
class Hello {
private World word
}
class World {
public BlaBlaBla foo()
}
Hel...
Inspiration asked 8/1, 2018 at 22:25
2
Solved
I'm experimenting with the reflection functionality in Kotlin, but I can't seem to understand how to obtain a KType value.
Suppose I have a class that maps phrases to object factories. In case of ...
Kotz asked 17/3, 2017 at 16:45
0
I'm using ProGuard for my spring boot application code. After I upgraded to Spring Boot 2, I cannot start my application anymore.
Spring Boot 2 uses kotlin-reflect to create beans, which uses kotl...
Rasia asked 15/1, 2019 at 14:18
1
Solved
Since I've been using kotlin-reflect to invoke my default and declared one, I see second different constructor.
I have realized that two different fields int arg3 and kotlin.jvm.internal.DefaultCo...
Wrongly asked 24/12, 2018 at 10:15
1
Solved
I have the following code:
import kotlin.reflect.KProperty1
infix fun <T, R> KProperty1<T, R>.eq(value: R) {
println(this.name + " = $value")
}
infix fun <T, R> KProperty1<...
Sciatic asked 9/10, 2018 at 9:45
1
Solved
I am trying to match the type of the nullable String? in a Kotlin reflection exercise:
data class Test(a: String, b: String?)
val test = Test("1", "2")
val properties = test::class.declaredMemberP...
False asked 25/9, 2018 at 1:1
4
Solved
Is there a way to merge kotlin data classes without specifying all the properties?
data class MyDataClass(val prop1: String, val prop2: Int, ...//many props)
with a function with the following s...
Asquint asked 15/6, 2017 at 11:41
1
Solved
I'm using org.jetbrains.kotlin:kotlin-reflect library in my project (included in gradle dependencies).
The app has been working without any problems however after upgrading android gradle plugin t...
Donahoe asked 28/3, 2018 at 12:19
1
Solved
I am trying to understand the reflection. I have the following code:
fun main(args: Array) {
println(lengthL1())
println(lengthL2(s))
println(lengthL1.get()) // Error
println(lengthL2.get(s)) // E...
Lopez asked 7/3, 2018 at 8:46
1
Solved
Warning: kotlin.reflect.jvm.internal.KClassImpl: can't find referenced class kotlin.reflect.jvm.internal.KClassImpl$kotlin.reflect.jvm.internal.KClassImpl$Data
Warning: kotlin.reflect.jvm.internal....
Despain asked 24/8, 2017 at 22:42
1
Solved
Given an interface method like this (Android Retrofit), how do I read the URL path specified in the annotation argument from Kotlin code at runtime?
ApiDefinition interface:
@GET("/api/somepath/o...
Hetzel asked 27/11, 2017 at 12:4
2
Solved
Looking for some help from someone who puts the pro in proguard.
Annotations used by kotlin-reflect (required dependency for jackson-module-kotlin v v2.8.8) are getting stripped out after upgradi...
Sinasinai asked 24/5, 2017 at 14:43
2
I have data class with default values.
data class Project(
val code: String,
val name: String,
val categories: List<String> = emptyList())
Java reflection fails to instantiate the clas...
Coquito asked 15/9, 2017 at 17:55
1
Solved
I'm playing with reflection and I came out with this problem. When using bound class reference via the ::class syntax, I get a covariant KClass type:
fun <T> foo(entry: T) {
with(entry::cla...
Mieshamiett asked 20/8, 2017 at 12:56
1
Solved
Given the following function
fun function(x: Int = 12) {
println("x = $x")
}
How can I using reflection invoke it without specifying x (or somehow using default value, not hard coding it)?
Academician asked 28/6, 2017 at 2:42
1
Solved
I am running some experiments on Kotlin's reflection.
I am trying to get a reflection object of a generic class with its argument.
In Java, that would be a ParameterizedType.
The way to get such...
Agleam asked 26/5, 2017 at 13:49
1
© 2022 - 2025 — McMap. All rights reserved.