Landry Norris

    Landry Norris

    3 months ago
    I noticed that androidx annotations is still an android-only library. With Compose and Datastore being experimentally KMM, is there any plan to move annotations over? This would help with models that I want to keep in commonMain, but may need annotations such as Keep (I need to access one model class via reflection in one project). Some, such as Discouraged, AnyThread, DoNotInline, ReturnThis, etc. may even be meaningful or useful in shared code.
    e

    ephemient

    3 months ago
    (your point still stands about usability from multiplatform, but it's not Android-only)
    Landry Norris

    Landry Norris

    3 months ago
    Good to know that it is also available on the JVM. I wonder what the reason was for not making it available on others as well? For some (especially reflection-related), it makes sense that they are only useful on JVM, but sometimes I still need shared code classes to behave a certain way on the JVM, but a no-op on other platforms is fine. Some are also fully meaningful on other platforms.
    e

    ephemient

    3 months ago
    all the amdroidx annotations were written in Java
    at this point I believe one is written in Kotlin, but that is far from making the whole library available multiplatform
    Landry Norris

    Landry Norris

    3 months ago
    I see. Changing it to Kotlin doesn't seem like it would be too hard, but I can also see that there are more important things for the androidx team to work on.
    If I expect/actual an annotation, I'd assume it still works, right? I mainly need Keep right now so I can use one class via reflection.
    e

    ephemient

    3 months ago
    I am not 100% sure if it'll work with Android Lint, but it should work with reflection and r8
    you might want
    @OptionalExpectation expect annotation class Keep
    so you only have to define
    actual typealias Keep
    in a JVM sourceset and leave it un-actualized in the JS/native sourcesets
    Landry Norris

    Landry Norris

    3 months ago
    That's interesting. I'll do that.
    k

    Kamil Kalisz

    3 months ago
    I can confirm that expect/actual works i did this for Parcelize annotation. You can check https://ankushg.com/posts/multiplatform-parcelize/