• f

    Fatih Yalmanbas

    1 year ago
    Hey guys, I have a problem using kotlin-reflect with r8 shrinker. I have tried investigating it but could not find the root cause any help would be appreciated. Please see 🧵 for more 🙂
    f
    2 replies
    Copy to Clipboard
  • christophsturm

    christophsturm

    1 year ago
    kotlin reflection on the jvm seems to be 100x slower than java reflection for some usecases. is that a known issue?
    christophsturm
    udalov
    5 replies
    Copy to Clipboard
  • TwoClocks

    TwoClocks

    1 year ago
    anyone know how to compare a KType to a actual type? I want to say something like
    if( someProp.returnType == Double::class )
    In this case I could create an instance of a
    Double
    and get it's type... but pretend the type is of a class that it's not easy/possible to get an instance of easily.
    TwoClocks
    d
    2 replies
    Copy to Clipboard
  • f

    F0X

    1 year ago
    Is it possible to cast a value to a
    KType
    or check whether a value is of the type (or if necessary the classifier)?
    f
    1 replies
    Copy to Clipboard
  • huehnerlady

    huehnerlady

    1 year ago
    Hi. I have a question. in the lib graphql-kotlin reflection is used to create GraphQL schema Types. If you are using a java class it will generate the types with all members being mandatory. After discussing with them they use reflection and the flag “isMarkedNullable” to determin if it is nullable or not. My question is: Why is the return type of the members of a Java class marked as non-nullable? Why is it not nullable as standard? Is there the possibility to determine if it is a javaclass or a kotlin class to work around that?
    huehnerlady
    1 replies
    Copy to Clipboard
  • s

    Sourabh Rawat

    1 year ago
    I want to get the name of the actual variable passed on the call site
    inline fun <reified T> foo(value: T?): T {
        println(::value.name) // get the name
    }
    
    foo(someValue) -> should output "someValue"
    foo(someValue2) -> should output "someValue2"
    I tried with https://kotlinlang.org/docs/reflection.html#property-references but to no avail. Is this even possible?
    s
    raulraja
    9 replies
    Copy to Clipboard
  • j

    jrod

    1 year ago
    i’m trying to integrate our Android app with an sdk which uses reflection to determine which methods of a callback interface have been implemented, i.e.,
    private fun getClientMetadata(callback: EventListener?) = ClientMetadata(
        Build.VERSION.SDK_INT,
        Build.MANUFACTURER,
        Build.MODEL,
        Build.PRODUCT,
        Build.DEVICE,
        Build.HARDWARE,
        callback != null && overridesMethod(callback::class, "onLogin"),
        callback != null && overridesMethod(callback::class, "onSuccess"),
        callback != null && overridesMethod(callback::class, "onError"),
        callback != null && overridesMethod(callback::class, "onExit"),
        callback != null && overridesMethod(callback::class, "onEvent"),
    )
    
    private fun getUnixTimestamp(): Long {
        return System.currentTimeMillis()
    }
    
    private fun overridesMethod(cls: KClass<out EventListener>, methodName: String): Boolean {
        return cls.memberFunctions.first { it.name == methodName } in cls.declaredFunctions
    }
    and i’m getting the following crash:
    j
    e
    2 replies
    Copy to Clipboard
  • j

    jeggy

    1 year ago
    Is it possible for me to create a function that would look something like this?
    j
    e
    4 replies
    Copy to Clipboard
  • TwoClocks

    TwoClocks

    1 year ago
    what's the difference between
    functions
    and
    memberFunctions
    and
    declaredFunctions
    and
    declaredMemberFunctions
    ? The docs don't point any obvious differences.
    TwoClocks
    e
    2 replies
    Copy to Clipboard
  • h

    henrik

    11 months ago
    From a function, can I easily resolve which function that called it?
    h
    christophsturm
    6 replies
    Copy to Clipboard