Why do Joda instants extend the raw type Comparable?

Joda's AbstractInstant interface extends the raw type Comparable, instead of Comparable, which seems to violate Java best practices. In particular, it means that I cannot use DateTime to parameterize a class like this:

class Foo> {
    public int ct(T a, T b) {
        return a.compareTo(b);
    }
}

It was my understanding this kind of class was perfectly valid (it certainly works with Double, etc.). To get it to work with DateTime, though, I have litter my own code with the raw type and suppressed warnings:

@SuppressWarnings("unchecked")
class Foo {
    public int ct(T a, T b) {
        return a.compareTo(b);
    }
}

There is a related question that suggests a workaround (wrapping the DateTime in another class for the purposes of comparison), but I don't see why that should be necessary. My question then is:

  1. Does anyone know why Joda is extending a raw type, or
  2. Is this a bug I should report to the library maintainers?

6
задан Community 23 May 2017 в 09:58
поделиться