Page MenuHomePhabricator

Update Java metrics platform client to support Kotlin
Closed, DeclinedPublic

Description

One of the planned features of the Metrics Platform client libraries is to conditionally produce events based on their properties (see T274175). A WIP Java implementation of this behavior is available here.

Dmitry suggested that Kotlin provides better support for the kind of introspection we need to do than using Java reflection. This task encompasses the work of (1) investigating what these operations would look like in Kotlin, and (2) updating the consolidated Java client library (T281757) to support Kotlin.

Event Timeline

Placeholder if we need to focus on interoperability

Mholloway triaged this task as Medium priority.
Mholloway moved this task from Backlog to Work in Progress on the Metrics-Platform board.
Mholloway moved this task from Inbox to Doing on the Product-Data-Infrastructure board.

This is the benefit that implementing the class in question in Kotlin would get us: https://kotlinlang.org/docs/reflection.html#property-references. It does look rather nice.

However, having spent a day hacking on it, I don't think it's something we should pursue at this point. For one thing, adding Kotlin support adds substantial complexity to the project. More importantly, although Kotlin offers support for multi-platform library builds, unless I'm missing something, it doesn't seem to be possible to write a single library targeting both the JVM and Android platforms, because those two targets rely on Gradle plugins that conflict with one another. Taking the step of adding Kotlin support and targeting Android would mean making this an Android-specific library rather than a general-purpose Java library, which I think is the opposite of our intent for these libraries.

My vote is to decline this and use good, old-fashioned Java reflection.

Declining this after discussion with the team. If a compelling case for incorporating Kotlin arises later, we can reopen.