Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

'Bound mismatch' error

843793Sep 7 2010 — edited Sep 7 2010
I have the following:
public abstract class General <T extends General<T>>
...
public class Particular1 extends General<Particular1>
...
public abstract class AbstractSequence<T extends General<T>> extends
		General<AbstractSequence<T>> implements Collection<T>
...
public class Particular2 extends AbstractSequence<Particular1>
...
public class Particular3 extends AbstractSequence<Particular2>
...
I get the following error:

Bound mismatch: The type Particular2 is not a valid substitute for the bounded parameter <T extends General<T>> of the type AbstractSequence<T>


But not if I do this:
public class Particular3 extends AbstractSequence<AbstractSequence<Particular1>>
I'm not sure exactly why, since after all Particular2 extends AbstractSequence<Particular1>.

The class AbstractSequence is supposed to be a 'sequence of General' type class. In the end the right answer is probably simply to make this an interface, say Sequence. This is annoying if it implements Collection, because then as soon as I want to implement Sequence, I need to implement a bunch of annoying unsupported Collection methods - but it doesn't really have to implement Collection. Nevertheless I'm curious as to why the other approach doesn't work.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 5 2010
Added on Sep 7 2010
1 comment
1,505 views