JNI Binding Errors when working with IComparable

I have the following Java class, which is used to generate the JAR file that I bind to

public abstract class AbstractSeries {
    public static abstract class AbstractPoint implements Comparable<AbstractPoint> {
        @Override
        public int compareTo(AbstractPoint another) {
            return Double.compare(mX, another.mX);
        }
    }
}

In Visual Studio I'm getting the following error:
'Com.Michaelpardo.Android.Widget.Chartview.LinearSeries.LinearPoint' does not implement inherited abstract member 'Com.Michaelpardo.Android.Widget.Chartview.AbstractSeries.AbstractPoint.CompareTo(Java.Lang.Object)'

I tried to fix the problem by doing this:

namespace Com.Michaelpardo.Android.Widget.Chartview
{
    public abstract partial class AbstractSeries 
    {
        public abstract partial class AbstractPoint
        {
            int Java.Lang.IComparable.CompareTo(Java.Lang.Object obj) 
            { 
                 return CompareTo((AbstractPoint)obj); 
            }
        }
    }
}

After I build the project I get the following error:
The type or namespace name 'Lang' does not exist in the namespace 'Com.Michaelpardo.Java' (Referencing the "Java.Lang.Object" parameter). Although, the intellisense picked it perfectly.

Can anyone propose a solution?

Thank you

Posts

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    Can anyone propose a solution?

    Use global keyword:

    partial class AbstractPoint {
        global::Java.Lang.IComparable.CompareTo(global::Java.Lang.Object obj)
        {
            return CompareTo ((AbstractPoint) obj);
        }
    }
    
Sign In or Register to comment.