Skip to content

Kotlin 1.6 metadata sometimes isn't applied  #945

@jpobst

Description

@jpobst

Context: dotnet/android-libraries#436 (comment)

In Kotlin 1.6, the name that Kotlin gives to the this method parameter that is in the first slot for a static method changed from $this to arg0:

// Kotlin
fun get (index: Int) : UInt { ... }
<!-- Kotlin 1.5.x -->
<method abstract="false" final="true" name="get-pVg5ArA" return="uint" jni-return="I" static="true" visibility="public" jni-signature="([II)I">
  <parameter name="$this" type="int[]" jni-type="[I" />
  <parameter name="index" type="int" jni-type="I" />
</method>

<!-- Kotlin 1.6.x -->
<method abstract="false" final="true" name="get-pVg5ArA" return="int" jni-return="I" static="true" visibility="public" jni-signature="([II)I">
  <parameter name="arg0" type="int[]" jni-type="[I" />
  <parameter name="index" type="int" jni-type="I" />
</method>

We were relying on ignoring parameters that start with a dollar sign in order to match Java methods with Kotlin function encodings. (This is, we need to ignore the first parameter and only match on the index parameter.)

In the linked Context, because we were not able to match the Kotlin metadata to the Java method, the fixups do not run. In this case, it means we do not convert Java's int to Kotlin's uint.

We will need to rework this logic to correctly handle parameters no matter what their name is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugComponent does not function as intendedgeneratorIssues binding a Java library (generator, class-parse, etc.)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions