Description
Problem
I'm trying to bind a library that has a dependency on this other library JNA (version 5.13.0) but when adding the JNA .jar
file and set it as Bind=False
on the csproj I'm getting one error regarding multiple interfaces having the same method, so basically it's like this:
public interface ToNativeConverter {
Object toNative(Object paramObject, ToNativeContext paramToNativeContext);
Class<?> nativeType();
}
public interface FromNativeConverter {
Object fromNative(Object paramObject, FromNativeContext paramFromNativeContext);
Class<?> nativeType();
}
public interface TypeConverter extends FromNativeConverter, ToNativeConverter {}
As you can see, both interfaces have Class<?> nativeType()
and that's why the ITypeConverter
fails when compiling the binding project:
The call is ambiguous between the following methods or properties: 'IFromNativeConverter.NativeType()' and 'IToNativeConverter.NativeType()'
On the generated code, it would be this:
static IntPtr n_NativeType (IntPtr jnienv, IntPtr native__this)
{
var __this = global::Java.Lang.Object.GetObject<global::Com.Sun.Jna.ITypeConverter> (jnienv, native__this, JniHandleOwnership.DoNotTransfer)!;
return JNIEnv.ToLocalJniHandle (__this.NativeType ()); // Here THE ERROR
}
Attempted non-working solutions
I attempted to create a new IBaseNativeConverter
in C# binding project with that method and remove the nodes from the two aforementioned interfaces and then just let IFromNativeConverter
and IToNativeConverter
implement IBaseNativeConverter
so we have the method in just one interface but then I get an error saying that the {From|To|Type}NativeConverterInvoker
does not implement my C# Java.Lang.Class? NativeType()
method.
Question
Should I implement a similar call like the above that was throwing an error on each ...Invoker
?
Or what can I do to fix this without changing the library java source code?
Notes:
Here you have the Metadata.xml
:
<attr path="/api/package[@name='com.sun.jna']/interface[@name='Callback']" name="name">ICallback</attr>
<remove-node path="/api/package[@name='com.sun.jna']/class[@name='JNIEnv']" />
And btw, I had to remove the node for JNIEnv
since that's being used by the Xamarin binding generator and was causing some problems on binding the lib.
Also, I attempted to create a separate binding project for JNA only and ended up with the same errors.