Bound mismatch with dependent eclipse projects

Viewed 51

This is my minimal reproducible example:

I have 3 classes:

package a;

import b.B;
import c.C;

public class A {
    B<C> bc = new B<C>();
}
package b;

import c.C;

public class B<T extends C> {
}
package c;

public class C {
}

Class A is in eclipse project "project_a"

Class B is in eclipse project "project_b"

Class C is in eclipse project "project_c"

project_a has project_b and project_c in its Modulepath

project_b has project_c in its Modulepath

There is nothing else in my workspace.

I get this compile error: Bound mismatch: The type C is not a valid substitute for the bounded parameter <T extends C> of the type B<T>

This doesn't make any sense. The C seen from project_a and the C seen from project_b should be the same!

Am I structuring the projects wrong?

If this is an issue in eclipse, what would be the best workaround without moving classes around?

1 Answers

When there are no module-info.java files, the dependent projects have to be on the Classpath, not on the Modulepath.

Related