[jnimarshalmethod-gen] JavaInterop1 marshal methods#1164
Merged
Conversation
Fixes: #1159 Context: c93fea0 `jnimarshalmethod-gen` is intended to generate marshal methods for any type that that: * Has `[JavaCallable]` (tested in `Java.Interop.Export-Tests.dll` and c93fea0), or * Overrides a `virtual` method which has `[JniMethodSignature]`, or * Implements an interface method which has `[JniMethodSignature]`. Thus, the intention was that it should generate marshal methods for `Java.Base-Tests`: % dotnet bin/Debug-net7.0/jnimarshalmethod-gen.dll -v bin/TestDebug-net7.0/Java.Base-Tests.dll Unable to read assembly 'bin/TestDebug-net7.0/Java.Base-Tests.dll' with symbols. Retrying to load it without them. Preparing marshal method assembly 'Java.Base-Tests-JniMarshalMethods' Processing Java.BaseTests.JavaInvoker type Processing Java.BaseTests.MyRunnable type Processing Java.BaseTests.MyIntConsumer type Marshal method assembly 'Java.Base-Tests-JniMarshalMethods' created Notably missing? No messages stating: Adding marshal method for … Also missing? `ikdasm bin/TestDebug-net7.0/Java.Base-Tests.dll` showed that there were no `__RegisterNativeMembers()` methods emitted. The `jnimarshalmethod-gen` invocation was a no-op! The problems were twofold: 1. It was only looking for methods with `Android.Runtime.RegisterAttribute`. This was useful for Xamarin.Android (when we were trying to make it work), but doesn't work with Java.Base. We need to *also* look for `Java.Interop.JniMethodSignature`. Relatedly, the attempt to use `registerAttribute.Constructor.Parameters` to determine parameter names didn't work; the parameter name was always `""`. 2. A'la c93fea0, we need to ensure that the Java `native` methods we register are consistent with `jcw-gen` output. Fix these two problems, which allows `jnimarshalmethod-gen` to now emit marshal methods for types within `Java.Base-Tests.dll`. Additionally, rework the `jnimarshalmethod-gen -f` logic to *remove* the existing `__<$>_jni_marshal_methods` nested type when present.
Contributor
Author
|
This should probably also incorporate additional |
…se+jnimarshalmethod-gen
jonathanpeppers
approved these changes
Nov 17, 2023
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #1159
Context: c93fea0
jnimarshalmethod-genis intended to generate marshal methods for any type that that:[JavaCallable](tested inJava.Interop.Export-Tests.dlland c93fea0), orvirtualmethod which has[JniMethodSignature], or[JniMethodSignature].Thus, the intention was that it should generate marshal methods for
Java.Base-Tests:Notably missing? No messages stating:
Also missing?
ikdasm bin/TestDebug-net7.0/Java.Base-Tests.dllshowed that there were no__RegisterNativeMembers()methods emitted.The
jnimarshalmethod-geninvocation was a no-op!The problems were twofold:
It was only looking for methods with
Android.Runtime.RegisterAttribute. This was useful for Xamarin.Android (when we were trying to make it work), but doesn't work with Java.Base. We need to also look forJava.Interop.JniMethodSignature.Relatedly, the attempt to use
registerAttribute.Constructor.Parametersto determine parameter names didn't work; the parameter name was always"".A'la c93fea0, we need to ensure that the Java
nativemethods we register are consistent withjcw-genoutput.Fix these two problems, which allows
jnimarshalmethod-gento now emit marshal methods for types withinJava.Base-Tests.dll.Additionally, rework the
jnimarshalmethod-gen -flogic to remove the existing__<$>_jni_marshal_methodsnested type when present.