JLS 3 Chapter 8 "Classes", section 8.1.2 "Generic Classes and Type Parameters"
provides the following example of mutually recursive type variable bounds:
interface ConvertibleTo<T> {
T convert();
}
class ReprChange<T implements ConvertibleTo<S>,
S implements ConvertibleTo<T>> {
T t;
void set(S s) { t = s.convert(); }
S get() { return t.convert(); }
}
But keyword "implements" is not allowed within type parameter declaration. Accrding to the JLS3 syntax rules
TypeParameter:
Identifier [extends Bound]
Due to that reason javac fails to compile the sample code.
Replacing "implements" with "extends" solves the problem.
provides the following example of mutually recursive type variable bounds:
interface ConvertibleTo<T> {
T convert();
}
class ReprChange<T implements ConvertibleTo<S>,
S implements ConvertibleTo<T>> {
T t;
void set(S s) { t = s.convert(); }
S get() { return t.convert(); }
}
But keyword "implements" is not allowed within type parameter declaration. Accrding to the JLS3 syntax rules
TypeParameter:
Identifier [extends Bound]
Due to that reason javac fails to compile the sample code.
Replacing "implements" with "extends" solves the problem.