FULL PRODUCT VERSION :
"1.5.0" build 1.5.0-b64
ADDITIONAL OS VERSION INFORMATION :
WindowsXP sp2
A DESCRIPTION OF THE PROBLEM :
The following code generates a compilation problem on the last line of class X: String s = secondInterface.find(new Integer(1));
SecondInterface has clearly specified String & Integer when it extends FirstInterface, and one should be able to invoke a method against a variable defined as a SecondInterface when the method is from the FirstInterface.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code that is supplied
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No compilation problem
ACTUAL -
Compilation error on the last statement in class X...
incompatible types
found : java.lang.Object
requried: java.lang.String
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Compilation error on the last statement in class X...
incompatible types
found : java.lang.Object
requried: java.lang.String
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
interface FirstInterface <O,N> {
public O find(N number);
}
interface SecondInterface <T extends CharSequence> extends FirstInterface<String, Integer> {
public String convert(T charSequence);
}
class SecondClass implements SecondInterface<StringBuilder> {
public String find(Integer i) { return null; }
public String convert(StringBuilder stringBuilder) { return null; }
}
class X {
public static void main(String[] args) {
SecondInterface secondInterface = new SecondClass();
secondInterface.find(new Integer(1));
String s = secondInterface.find(new Integer(1));
}
}
---------- END SOURCE ----------
"1.5.0" build 1.5.0-b64
ADDITIONAL OS VERSION INFORMATION :
WindowsXP sp2
A DESCRIPTION OF THE PROBLEM :
The following code generates a compilation problem on the last line of class X: String s = secondInterface.find(new Integer(1));
SecondInterface has clearly specified String & Integer when it extends FirstInterface, and one should be able to invoke a method against a variable defined as a SecondInterface when the method is from the FirstInterface.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code that is supplied
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No compilation problem
ACTUAL -
Compilation error on the last statement in class X...
incompatible types
found : java.lang.Object
requried: java.lang.String
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Compilation error on the last statement in class X...
incompatible types
found : java.lang.Object
requried: java.lang.String
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
interface FirstInterface <O,N> {
public O find(N number);
}
interface SecondInterface <T extends CharSequence> extends FirstInterface<String, Integer> {
public String convert(T charSequence);
}
class SecondClass implements SecondInterface<StringBuilder> {
public String find(Integer i) { return null; }
public String convert(StringBuilder stringBuilder) { return null; }
}
class X {
public static void main(String[] args) {
SecondInterface secondInterface = new SecondClass();
secondInterface.find(new Integer(1));
String s = secondInterface.find(new Integer(1));
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-6244346 Unnecessary unchecked warning (result type should not be erased)
-
- Closed
-