Hello,
I'm working on a project and with eclipse I can compile my whole project without any problems.
But when I try it manually with javac I get an incompatible types; no instance(s) of type variable(s) error :(
The error message is:
PlayerFactory.java:8: incompatible types; no instance(s) of type variable(s) S exist so that Player<T,S> conforms to Player<T,S>
found : <S>Player<T,S>
required: Player<T,S>
return createRemotePlayer((RemotePlayerInfo)info, termfactory);
1 error
I localize the problem files and delete all contents to show you the problem.
When you try to compile this you get the error:
public abstract class AbstractPlayer<
T extends TermInterface,
S extends StateInterface<T,S>
> implements Player<T,S> {
}
public interface Player<
T extends TermInterface,
S extends StateInterface<T,S>
> {
}
public class RemotePlayer<
T extends TermInterface,
S extends StateInterface<T,S>
> extends AbstractPlayer<T,S> {
}
public interface TermInterface {
}
public interface StateInterface<T extends TermInterface, S extends StateInterface<T,S>> {
}
public class RemotePlayerInfo extends PlayerInfo {
}
public abstract class PlayerInfo {
}
public interface TermFactoryInterface<T extends TermInterface> {
}
public class PlayerFactory {
public static <T extends TermInterface, S extends StateInterface<T, S>> Player<T,S> createRemotePlayer(RemotePlayerInfo info, TermFactoryInterface<T> termfactory) {
return new RemotePlayer<T,S>();
}
public static <T extends TermInterface, S extends StateInterface<T, S>> Player<T,S> createPlayer(PlayerInfo info, TermFactoryInterface<T> termfactory) {
if(info instanceof RemotePlayerInfo){
return createRemotePlayer((RemotePlayerInfo)info, termfactory);
}
return null;
}
}
Do you have an idea where the problem is?
Thank you so much!
Martin