-
Bug
-
Resolution: Unresolved
-
P4
-
5.0, 7, 8
-
generic
-
generic
The following shows that javac is inconsistent in determining
which overriders are allowed:
class Box<T extends Number> {}
class T1 { // works
static class A {
void f(Box<?> box) {}
}
static class B extends A {
void f(Box<? extends Object> box) {}
}
}
class T2 { // works
static class A {
void f(Box<?> box) {}
}
static class B extends A {
void f(Box<? extends Number> box) {}
}
}
class T3 { // works
static class A {
void f(Box<? extends Object> box) {}
}
static class B extends A {
void f(Box<?> box) {}
}
}
class T4 { // works
static class A {
void f(Box<? extends Number> box) {}
}
static class B extends A {
void f(Box<?> box) {}
}
}
class T5 { // fails
static class A {
void f(Box<? extends Object> box) {}
}
static class B extends A {
void f(Box<? extends Number> box) {}
}
}
which overriders are allowed:
class Box<T extends Number> {}
class T1 { // works
static class A {
void f(Box<?> box) {}
}
static class B extends A {
void f(Box<? extends Object> box) {}
}
}
class T2 { // works
static class A {
void f(Box<?> box) {}
}
static class B extends A {
void f(Box<? extends Number> box) {}
}
}
class T3 { // works
static class A {
void f(Box<? extends Object> box) {}
}
static class B extends A {
void f(Box<?> box) {}
}
}
class T4 { // works
static class A {
void f(Box<? extends Number> box) {}
}
static class B extends A {
void f(Box<?> box) {}
}
}
class T5 { // fails
static class A {
void f(Box<? extends Object> box) {}
}
static class B extends A {
void f(Box<? extends Number> box) {}
}
}
- relates to
-
JDK-7023317 The compiler allows a class with multiple methods the same signature.
- Closed
-
JDK-6480391 Unbounded wildcard '?' means '? extends Object'
- Closed