java-oo
java-oo copied to clipboard
java-oo does not work for class whose superclass is parametrized by generic type
public abstract class Abstract {
static class Base<T> {
public T add(T a) {
return a;
}
}
static class Ext extends Base<Integer> {
}
public static boolean test() {
Integer a = new Ext().add(new Integer(1)); // this can compile
Integer b = new Ext() + new Integer(1); // this can not compile!
return true;
}
}
Running JCPOOTest
Note: Injecting OO to javac8
../tests/Abstract.java:14: error: incompatible types: T cannot be converted to Integer
Integer b = new Ext() + new Integer(1); // this can not compile!
^
where T is a type-variable:
T extends Object declared in class Base
1 error