[Java.Interop.Tools.JavaCallableWrappers] [Export]+params #1161
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: dotnet/android#7554
Placing
[Export]
on a constructor with parameters did not work as expected. Consider:This does generate a Java Callable Wrapper with the desired constructor, but it doesn't invoke the correct C# constructor, because of the
TypeManager.Activate()
invocation:In particular, because
signature
is the empty string,TypeManager.Activate()
will lookup and invoke the default constructor, rather than theExample(int)
constructor. (This despite the fact thatparameterList
contains arguments!)Consequently, when Java invokes the
Example(int)
constructor, an exception is thrown, as the default constructor it wants doesn't exist:Update
JavaCallableWrapperGenerator.AddConstructor()
so that themanagedParameters
value is provided to theSignature
instance for the[Export]
constructor. This value is then inserted as thesignature
parameter value, which will allow the correct constructor to be invoked: