简体   繁体   中英

remove virtual keyword from xamarin java binding

Currently I'm trying to convert a jar file to dll with Xamarin Java Binding project.

Here is the java code public int compareTo(java.lang.object paramPGAbsEffect)

which becomes public virtual unsafe int CompareTo (object p0) in my c# code. I want to just remove the virtual keyword, because it is not there in Java file.

I tried ... /method[@name='compareTo']" name="virtual">false but this is not working.

All Java functions are virtual by default, unless you use final keyword. Thus, the tool just does its job and you should learn more about both Java and C#.

The solution is to set final to true in the Metadata.xml mapping:

<attr 
   path="/api/package[@name='your.package.here']/class[@name='YourClass.InnerClass']/method[@name='methodName']" 
   name="final">true</attr>

This effectively removes the virtual keyword from the method signature, and doesn't add the final keyword either. Strange behavior, but it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM