I'm no Java expert but I can usually figure out the errors I encounter when working with it. This particular one however has me scratching my head.
I have the following class (with unnecessary fluff removed for ease of reading this post)
package miui.content.res;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.content.res.Configuration;
import android.os.Parcel;
import android.os.RemoteException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public class ExtraConfiguration
implements Comparable<ExtraConfiguration>
{
public int themeChanged;
public int compareTo(ExtraConfiguration that)
{
return this.themeChanged - that.themeChanged;
}
}
To me, this seems pretty straight forward but upon compilation I get the following error:
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/miui/content/res/ExtraConfiguration.java:2:
name clash:
compareTo(java.lang.Object) in miui.content.res.ExtraConfiguration and
compareTo(T) in java.lang.Comparable<miui.content.res.ExtraConfiguration>
have the same erasure, yet neither overrides the other
I did some brushing up on the concept of erasure, and the compareTo() method I show in the code snippet is the only one in the ExtraConfiguration class. At this point I am not sure what the issue is.
This particular class is from an Android framework for a ROM known as MIUI which I am trying to duplicate from some decompiled source. In the meantime I have simply removed the 'implements Comparable
Thanks in advance.
You should be able to do this to get around it, but I can't explain why you are getting the error:
public class ExtraConfiguration
implements Comparable<Object>
{
public int themeChanged;
public int compareTo(Object that)
{
if (!(that instanceof ExtraConfiguration)) {
throw new ClassCastException();
} else {
return compareTo((ExtraConfiguration) that);
}
}
public int compareTo(ExtraConfiguration that)
{
return this.themeChanged - that.themeChanged;
}
}