Skip to content

Conversation

@moljac
Copy link
Contributor

@moljac moljac commented Dec 3, 2021

Updated aritfact bindings

  • androidx.annotation:annotation - 1.2.0 -> 1.3.0

    • Xamarin.AndroidX.Annotation

  • androidx.collection:collection - 1.1.0 -> 1.2.0

    • Xamarin.AndroidX.Collection

  • androidx.collection:collection-ktx - 1.1.0 -> 1.2.0

  • androidx.compose.animation:animation - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.animation:animation-core - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.foundation:foundation - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.foundation:foundation-layout - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.material:material - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.material:material-icons-core - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.material:material-icons-extended - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.material:material-ripple - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.runtime:runtime - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.runtime:runtime-livedata - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.runtime:runtime-rxjava2 - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.runtime:runtime-saveable - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.ui:ui - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.ui:ui-geometry - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.ui:ui-graphics - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.ui:ui-text - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.ui:ui-unit - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.ui:ui-util - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.compose.ui:ui-viewbinding - 1.0.0 -> 1.0.5

    • no API changes
  • androidx.constraintlayout:constraintlayout - 2.1.1 -> 2.1.2

  • androidx.constraintlayout:constraintlayout-core - 1.0.1 -> 1.0.2

    • no API changes
  • androidx.emoji2:emoji2 - -> 1.0.0

    • no API changes
  • androidx.emoji2.emoji2

  • androidx.emoji2:emoji2-views-helper - -> 1.0.0

  • androidx.resourceinspection:resource-inspection-annotation - -> 1.0.0

    • no API changes
  • androidx.lifecycle:lifecycle-common - 2.3.1 -> 2.4.0

    • Xamarin.AndroidX.Lifecycle.Common

  • androidx.lifecycle:lifecycle-common-java8 - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle:lifecycle-livedata - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle:lifecycle-livedata-core - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle:lifecycle-livedata-core-ktx - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle:lifecycle-livedata-ktx - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle:lifecycle-process - 2.3.1 -> 2.4.0

  • androidx.lifecycle:lifecycle-reactivestreams - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle:lifecycle-reactivestreams-ktx - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle:lifecycle-runtime - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle:lifecycle-runtime-ktx - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle.lifecycle-runtime-ktx

    • Xamarin.AndroidX.Lifecycle.Runtime.Ktx

  • androidx.lifecycle:lifecycle-service - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle:lifecycle-viewmodel - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle.lifecycle-viewmodel

  • androidx.lifecycle:lifecycle-viewmodel-ktx - 2.3.1 -> 2.4.0

  • androidx.lifecycle:lifecycle-viewmodel-savedstate - 2.3.1 -> 2.4.0

    • no API changes
  • androidx.lifecycle.lifecycle-viewmodel-savedstate

    • Xamarin.AndroidX.Lifecycle.ViewModelSavedState

  • androidx.paging:paging-common - 3.0.1 -> 3.1.0

  • androidx.paging:paging-common-ktx - 3.0.1 -> 3.1.0

    • no API changes
  • androidx.paging:paging-runtime - 3.0.1 -> 3.1.0

    • no API changes
  • androidx.paging.paging-runtime

    • Xamarin.AndroidX.Paging.Runtime

  • androidx.paging:paging-runtime-ktx - 3.0.1 -> 3.1.0

    • no API changes
  • androidx.paging:paging-rxjava2 - 3.0.1 -> 3.1.0

    • no API changes
  • androidx.paging:paging-rxjava2-ktx - 3.0.1 -> 3.1.0

    • no API changes
  • androidx.profileinstaller:profileinstaller - 1.0.0 -> 1.0.4

    • no API changes
  • androidx.profileinstaller.profileinstaller

  • androidx.work:work-runtime - 2.7.0 -> 2.7.1

    • Xamarin.AndroidX.Work.Runtime

  • androidx.work:work-runtime-ktx - 2.7.0 -> 2.7.1

    • no API changes
  • io.reactivex.rxjava3:rxjava - 3.1.2 -> 3.1.3

    • no API changes
  • org.jetbrains:annotations - 22.0.0 -> 23.0.0

    • Xamarin.Jetbrains.Annotations

Changed but not updated

  • androidx.appcompat.appcompat

  • androidx.biometric.biometric

    • Xamarin.AndroidX.Biometric

  • androidx.core.core

  • androidx.leanback.leanback

  • androidx.recyclerview.recyclerview

    • Xamarin.AndroidX.RecyclerView

  • androidx.resourceinspection.resourceinspection-annotation

  • androidx.security.security-crypto

  • androidx.webkit.webkit

  • androidx.window.window

  • androidx.window.window-java

  • com.google.android.material.material

  • com.google.code.gson.gson

  • com.google.crypto.tink.tink-android

  • io.reactivex.rxjava2.rxjava

  • org.jetbrains.kotlin.kotlin-stdlib

  • org.reactivestreams.reactive-streams

    • Xamarin.Android.ReactiveStreams

@PawKanarek
Copy link

Hello @moljac i see that some checks have failed due to

@azure-pipelinesazure-pipelines
/ AndroidX (Build macos)
Build log #L14
Error: Certificate "Apple Development: Matthew Leibowitz (Q3RH4N7S8Y)" (fingerprint: AF4469EF01A461E3994C42E2FBF6C0159AF6FB67) expired on Sun Dec 26 2021 00:22:38 GMT+0000 (Coordinated Universal Time)

Do you have idea when this PR will be merged?
I'm asking because I have to bind newest native exoPlayer 2.16.1 library into Xamarin library and it requires dependency androidx.annotation:annotation 1.3.0 which should created in this PR. Without xamarin.annotation 1.3.0 i cannot move any further.

@moljac
Copy link
Contributor Author

moljac commented Jan 19, 2022

@PawKanarek

After this one

#453

is approved/merged and packages published I can continue with updates and this PR should be 1st

@moljac moljac requested a review from jpobst January 27, 2022 12:21
config.json Outdated
"version": "1.0.0",
"nugetVersion": "1.0.0",
"nugetId": "Xamarin.AndroidX.Emoji2",
"excludedRuntimeDependencies": "androidx.lifecycle.lifecycle-process",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be an actual needed runtime dependency. Removing it will likely cause this package to not work:

    <dependency>
      <groupId>androidx.lifecycle</groupId>
      <artifactId>lifecycle-process</artifactId>
      <version>2.4.0</version>
      <scope>runtime</scope>
      <type>aar</type>
    </dependency>

config.json Outdated
"artifactId": "kotlin-stdlib",
"version": "1.5.31",
"nugetVersion": "1.5.31.3",
"version": "1.6.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to hold off on updating Kotlin to 1.6.0. Looking at the diffs makes me think they may have changed how they are encoding their "unsigned" types, and we may need a fix there or else all of our Kotlin support around them will be incorrect.

Example: these changed from uint to int for a type called UIntArray:

Type Changed: Kotlin.UIntArray

Removed methods:

public static uint Get (int[] _this, int index);
public static void Set (int[] _this, int index, uint value);

Added methods:

public static int Get (int[] arg0, int index);
public static void Set (int[] arg0, int index, int value);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like API was changed:

Type Changed: Kotlin.UByteArray

Removed methods:

public static byte Get (byte[] _this, int index);
public static void Set (byte[] _this, int index, byte value);
public virtual int Size ();

Decompiled:

public final class UByteArray implements Collection<UByte>, KMappedMarker
{
    // removed
    
    public static final byte get-w2LRezQ(final byte[] arg0, final int index) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        return UByte.constructor-impl(arg0[index]);
    }
    
    public static final void set-VurrAj0(final byte[] arg0, final int index, final byte value) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        arg0[index] = value;
    }
    
    public static int getSize-impl(final byte[] arg0) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        return arg0.length;
    }
    
    public int getSize() {
        return getSize-impl(this.storage);
    }

    // removed
}

Type Changed: Kotlin.UIntArray

Removed interfaces:

Java.Lang.IIterable
Java.Util.ICollection

Removed methods:

public static uint Get (int[] _this, int index);
public static void Set (int[] _this, int index, uint value);
public virtual int Size ();

Decompiled:

public final class UIntArray implements Collection<UInt>, KMappedMarker
{
    // removed

    public static final int get-pVg5ArA(final int[] arg0, final int index) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        return UInt.constructor-impl(arg0[index]);
    }
    
    public static final void set-VXSXFK8(final int[] arg0, final int index, final int value) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        arg0[index] = value;
    }
    
    // removed
}

Type Changed: Kotlin.ULongArray

Removed methods:

public static ulong Get (long[] _this, int index);
public static void Set (long[] _this, int index, ulong value);
public virtual int Size ();

Decompiled:

public final class ULongArray implements Collection<ULong>, KMappedMarker
{
    // removed
    
    public static final long get-s-VKNKU(final long[] arg0, final int index) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        return ULong.constructor-impl(arg0[index]);
    }
    
    public static final void set-k8EXiF4(final long[] arg0, final int index, final long value) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        arg0[index] = value;
    }
    
    public static int getSize-impl(final long[] arg0) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        return arg0.length;
    }
    
    public int getSize() {
        return getSize-impl(this.storage);
    }

    // removed
}

Type Changed: Kotlin.UShortArray

Removed methods:

public static ushort Get (short[] _this, int index);
public static void Set (short[] _this, int index, ushort value);
public virtual int Size ();

Decompiled:

public final class UShortArray implements Collection<UShort>, KMappedMarker
{
    // removed
    
    public static final short get-Mh2AYeg(final short[] arg0, final int index) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        return UShort.constructor-impl(arg0[index]);
    }
    
    public static final void set-01HTLdE(final short[] arg0, final int index, final short value) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        arg0[index] = value;
    }
    
    public static int getSize-impl(final short[] arg0) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        return arg0.length;
    }
    
    public int getSize() {
        return getSize-impl(this.storage);
    }

    // removed
}

config.json Outdated
"artifactId": "activity",
"version": "1.3.1",
"nugetVersion": "1.3.1.2",
"nugetVersion": "1.3.1.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's about 20 artifacts that are bumping the nugetVersion but are not bumping the artifact version, What is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember. It was begining of December. I might have rebased/merged some change from other PRs

@moljac moljac requested a review from jpobst January 31, 2022 18:53
@moljac moljac merged commit 2dc46c6 into main Jan 31, 2022
@moljac moljac deleted the wsu-20211202 branch January 31, 2022 20:00
jonpryor pushed a commit to dotnet/java-interop that referenced this pull request Feb 7, 2022
Fixes: #945

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

Consider the following Kotlin function:

	fun get (index: Int) : UInt { … }

When `get` is compiled with Kotlin 1.5, `class-parse` would emit:

	<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>

However, when `get` is compiled with Kotlin 1.6, `class-parse` sees:

	<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>

Note that the name of the first `int[]` parameter changes from
`$this` to `arg0`, and the return type changed from `uint` to `int`.

The parameter name change is annoying; the return type change is
an ABI break, and makes many package updates impossible.

What happened?

Recall commit 71afce5: Kotlin-compiled `.class` files contain a
`kotlin.Metadata` type-level annotation blob, which contains a
Protobuf stream containing Kotlin metadata for the type.
The `kotlin.Metadata` annotation contains information about Kotlin
functions, and `class-parse` needs to associate the information about
the Kotlin functions to Java methods.  This can be tricky because
there is not an explicit way to do this, and one must rely on trying
to match function names and parameter types.  Previously, this was
accomplished by looping through the parameters and comparing types.

However, the `kotlin.Metadata` annotation only includes "user created"
method parameters, while the Java method may include "compiler created"
method parameters.  We attempted to skip these by ignoring Java
parameters whose names begin with a dollar sign (ex `$this`).

This "worked" most of the time.

This broke in Kotlin 1.6, as the compiler generated method parameters
stopped using `$` for compiler-generated parameter names.
algorithm.

We need something better.

The `kKotlin.Metadata` annotation provides a `JvmSignature` property --
which matches the `JvmName` property which we already use -- which
sounds promising.  However, `JvmSignature` is sometimes `null`, and
sometimes it doesn't actually match.  But it's closer.

So now we try to match with signatures.

  * If `JvmSignature` matches the Java signature we use that.

  * If `JvmSignature` is `null`, calculate it from the Kotlin
    parameters and try to match with that.
    * Note it wants unsigned types as `Lkotlin/UInt;` and not the
      primitive encoding (`I`).

  * If Kotlin metadata defines a `ReceiverType`, add that as the
    first parameter to the signature.

Using `kotlin-stdlib-1.5.31.jar` as a baseline, we get much better
results:

| Version         | Matched Functions |   Unmatched Functions |
| --------------- | ----------------: | --------------------: |
| main @ 32635fd |               946 |                   154 |
| This PR         |              1100 |                     0 |

Now that we can match Kotlin functions to Java methods, we still have
to match up the parameters so we can apply parameter-level transforms.
Do this by removing Java method parameters from the front and back of
the list to account for cases where the compiler adds "hidden"
parameters:

  * Remove Kotlin `ReceiverType` from beginning of list.
  * Remove Kotlin `Lkotlin/coroutines/Continuation;` from end of list.
    * Note this _could_ be a legitimate user supplied parameter so we
      try to restrict it to "unnamed" parameters.
  * Remove the `this` parameter added to `static` functions.

Note: the test classes `DeepRecursiveKt.class`,
`DeepRecursiveScope.class`, and `UByteArray.class` are pulled from
[`kotlin-stdlib-1.5.31.jar`][0].

[0]: https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib/1.5.31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants