I\'m upgrading some code to Java 5 and am clearly not understanding something with Generics. I have other classes which implement Comparable once, which I\'ve been able to i
Having multiple implementations of generic interfaces would run into problems when you consider wildcards.
This does not depend upon erasure.
Generics don't exist after bytecode has been compiled.
Restrictions from this: You can't implement / extend two or more interfaces / classes that would be same without the generic parameter and are different with the generic parameter.
What you could do if you really really want type safety is:
interface Foo<T extends Foo<?>> extends Comparable<T>
interface Bar<T extends Bar<?>> extends Comparable<T>
abstract class BarDescription<T extends Bar<?>> implements Bar<T>
class FooBar extends BarDescription<FooBar> implements Foo<FooBar>
I'd write a couple of Comparator
s and be done with it.