Skip to content

Conversation

@jpobst
Copy link
Contributor

@jpobst jpobst commented Oct 28, 2021

Support Libraries Version (eg: 23.3.0):

Does this change any of the generated binding API's?

Describe your contribution

@jpobst jpobst force-pushed the test-java-type-system branch 6 times, most recently from 244613d to a7c698f Compare November 1, 2021 19:52
@jpobst jpobst force-pushed the test-java-type-system branch from a7c698f to 834140d Compare November 4, 2021 13:54
jonpryor pushed a commit to dotnet/java-interop that referenced this pull request Nov 23, 2021
…919)

While [testing][0] the new JavaTypeSystem (f658ab2) on [AndroidX][1],
the api-diff was reporting various constructors had been removed:

	## Xamarin.Android.Glide.dll
	#### Type Changed: Bumptech.Glide.Registry.NoModelLoaderAvailableException
	
	Removed constructor:
	
	```csharp
	public Registry.NoModelLoaderAvailableException (Java.Lang.Object model, System.Collections.IList matchingButNotHandlingModelLoaders);
	```
	
	Investigating let to realizing Java constructors can have generic type parameters:
	
	```java
	  public static class NoModelLoaderAvailableException extends MissingComponentException {
	  
	    public <M> NoModelLoaderAvailableException(
	        @nonnull M model, @nonnull List<ModelLoader<M, ?>> matchingButNotHandlingModelLoaders) {
	      super(
	          "Found ModelLoaders for model class: "
	              + matchingButNotHandlingModelLoaders
	              + ", but none that handle this specific model instance: "
	              + model);
	    }
	```

[(source)][2]

`class-parse` correctly emits these constructors with generic types:

	```xml
	<constructor
	  deprecated="not deprecated"
	  final="false"
	  name="Registry.NoModelLoaderAvailableException"
	  static="false"
	  visibility="public"
	  bridge="false"
	  synthetic="false"
	  jni-signature="(Ljava/lang/Object;Ljava/util/List;)V">
	  <typeParameters>
	    <typeParameter
	      name="M"
	      jni-classBound="Ljava/lang/Object;"
	      classBound="java.lang.Object"
	      interfaceBounds=""
	      jni-interfaceBounds="" />
	  </typeParameters>
	  <parameter
	    name="model"
	    type="M"
	    jni-type="TM;"
	    not-null="true" />
	  <parameter
	    name="matchingButNotHandlingModelLoaders"
	    type="java.util.List&lt;com.bumptech.glide.load.model.ModelLoader&lt;M, ?&gt;&gt;"
	    jni-type="Ljava/util/List&lt;Lcom/bumptech/glide/load/model/ModelLoader&lt;TM;*&gt;;&gt;;"
	    not-null="true" />
	</constructor>
	```

We need to import this information in JavaTypeSystem so that the type
parameters can be resolved.  Without them, the constructor is omitted
because the type `M` cannot be resolved:

	The constructor 'Constructor: com.bumptech.glide.Registry.NoModelLoaderAvailableException.Registry.NoModelLoaderAvailableException'
	was removed because the Java parameter type 'M' could not be found.

Tested against AndroidX and this change restores the constructors.

[0]: dotnet/android-libraries#414
[1]: https://github.com/xamarin/AndroidX
[2]: https://github.com/bumptech/glide/blob/master/library/src/main/java/com/bumptech/glide/Registry.java
@jpobst jpobst closed this Nov 29, 2021
@jpobst jpobst deleted the test-java-type-system branch November 29, 2021 19:51
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.

2 participants