Skip to content

Instantly share code, notes, and snippets.

@filiphr
Last active October 13, 2018 21:50
Show Gist options
  • Save filiphr/d37eb087360986e6b65184a66a2b4cf1 to your computer and use it in GitHub Desktop.
Save filiphr/d37eb087360986e6b65184a66a2b4cf1 to your computer and use it in GitHub Desktop.
Differences between javac and tycho-compiler-jdt (1.2.0)
public interface Animal<ID extends KeyOfAllBeings> extends Identifiable<KeyOfAllBeings> {
@Override
ID getKey();
void setKey(ID item);
}
public class AnimalKey extends KeyOfAllBeings {
}
public abstract class BaseAnimal implements Identifiable<KeyOfAllBeings>, Animal<AnimalKey> {
}
public class Elephant extends BaseAnimal {
private AnimalKey key;
@Override
public AnimalKey getKey() {
return key;
}
@Override
public void setKey(AnimalKey key) {
this.key = key;
}
}
public interface Identifiable<T extends Key> {
T getKey();
}
public class Key {
}
public class KeyOfAllBeings extends Key {
}
public class Main {
public static void main(String[] args) {
BaseAnimal baseAnimal = new Animal();
// Both work on javac, but not ecj (at least not with tycho-compiler-jdt 1.2.0)
AnimalKey key = baseAnimal.getKey();
KeyOfAllBeings key2 = baseAnimal.getKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment