-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b03
-
sparc
-
solaris_9
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2152450 | OpenJDK6 | Jonathan Gibbons | P3 | Closed | Not an Issue |
generic class signature allows to extends the same interface multiple times.
Ideally it should throw compile time here.
Please find the below code. It compiles successfully. But I think it shouldn't compile it. Class B signature allows to extends the MyInterface<E> twice.
//-- Code start here --
//Test1.java
import java.lang.reflect.*;
public class Test1 {
public static void main(String[] args) {
B b = new B<Sun1>();
}
}
class D { }
interface MyInterface<E> {
public String foo();
}
class MyClass { }
class Sun1 extends MyClass implements MyInterface<Sun1>, MyInterface<Sun1> {
public String foo() {
return "test";
}
}
class B < E extends MyClass & MyInterface<E> & MyInterface<E> > extends D {
}
//-- code end here
Ideally it should throw compile time here.
Please find the below code. It compiles successfully. But I think it shouldn't compile it. Class B signature allows to extends the MyInterface<E> twice.
//-- Code start here --
//Test1.java
import java.lang.reflect.*;
public class Test1 {
public static void main(String[] args) {
B b = new B<Sun1>();
}
}
class D { }
interface MyInterface<E> {
public String foo();
}
class MyClass { }
class Sun1 extends MyClass implements MyInterface<Sun1>, MyInterface<Sun1> {
public String foo() {
return "test";
}
}
class B < E extends MyClass & MyInterface<E> & MyInterface<E> > extends D {
}
//-- code end here
- backported by
-
JDK-2152450 (compound) same interface allowed twice in compound type
- Closed