-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#1266) Context: #1268 Context: 78d5937 Commit 78d5937 included this snippet: > Update `generator` to support using `Java.Base.dll` as a referenced > assembly for binding purposes, in particular by supporting the use > of `[JniTypeSignatureAttribute]` on already bound types. Aside: the symbol table used by `generator` uses the "full Java name" as the key. Which means that after 78d5937, types with `JniTypeSignatureAttribute.SimpleReference` values are now added to the symbol table, which in turn means that when given: // C# [JniTypeSignature ("B", ArrayRank=1, IsKeyword=true, GenerateJavaPeer=false)] public sealed partial class JavaSByteArray : JavaPrimitiveArray<SByte> { } when `generator` needs to find type information corresponding to the Java name of `B`, it will find `JavaSByteArray`! This apparently breaks binding the [`androidx.work:work-runtime`][0] Maven package, as [`androidx.work.WorkRequest.Builder.setId(UUID)`][1] has a return type of `B`, a generic type parameter: // Java public abstract /* partial */ class androidx.work.WorkRequest.Builder< B extends androidx.work.WorkRequest$Builder<B, ?>, W extends androidx.work.WorkRequest> { public final B setId(java.util.UUID); } As a workaround, only use `[JniTypeSignature]` when using `generator --codegen-target=JavaInterop1`. `generator --codegen-target=XAJavaInterop1` will only look for `[RegisterAttribute]` when constructing the symbol table. This commit plumbs `CodeGenerationOptions` deeper into `generator` and a new `ApiImporterOptions` into `Java.Interop.Tools.JavaTypeSystem` that is used to determine whether we should be importing `[JniTypeSignatureAttribute]` types. TODO? #1268 [0]: https://maven.google.com/web/index.html#androidx.work:work-runtime [1]: https://developer.android.com/reference/androidx/work/WorkRequest.Builder?hl=en#setId(java.util.UUID)
- Loading branch information
Showing
7 changed files
with
90 additions
and
68 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/Java.Interop.Tools.JavaTypeSystem/Adapters/ApiImporterOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Java.Interop.Tools.JavaTypeSystem; | ||
|
||
public class ApiImporterOptions | ||
{ | ||
public Collection<string> SupportedTypeMapAttributes { get; } = ["Android.Runtime.RegisterAttribute"]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.