FULL PRODUCT VERSION :
ava version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux nacar 2.6.18-suspend2-r1 #3 PREEMPT Tue Dec 26 21:51:39 COT 2006 i686 Intel(R) Pentium(R) M processor 2.00GHz GenuineIntel GNU/Linux
A DESCRIPTION OF THE PROBLEM :
A qualified reference to a static parametrized class method is reported as ambiguous by javac when the method hides one in its super class using different type parameters.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the following code:
---
class A {
public static Object create() {
return null;
}
}
class B extends A {
public static<T> Object create() {
return null;
}
public static void main(String... args) {
Object b=B.create();
}
}
---
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
clean compilation
:)
ACTUAL -
... reference to create is ambiguous, both method create() in A and method <T>create() in B match
Object b=B.create();
^
1 error
:(
ERROR MESSAGES/STACK TRACES THAT OCCUR :
... reference to create is ambiguous, both method create() in A and method <T>create() in B match
Object b=B.create();
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class A {
public static Object create() {
return null;
}
}
class B extends A {
public static<T> Object create() {
return null;
}
public static void main(String... args) {
Object b=B.create();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
- do not hide static methods with different type parameter specifications. (Use other method name)... But this makes my code more difficult to use because a more complex coding pattern must be followed. :(
ava version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux nacar 2.6.18-suspend2-r1 #3 PREEMPT Tue Dec 26 21:51:39 COT 2006 i686 Intel(R) Pentium(R) M processor 2.00GHz GenuineIntel GNU/Linux
A DESCRIPTION OF THE PROBLEM :
A qualified reference to a static parametrized class method is reported as ambiguous by javac when the method hides one in its super class using different type parameters.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the following code:
---
class A {
public static Object create() {
return null;
}
}
class B extends A {
public static<T> Object create() {
return null;
}
public static void main(String... args) {
Object b=B.create();
}
}
---
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
clean compilation
:)
ACTUAL -
... reference to create is ambiguous, both method create() in A and method <T>create() in B match
Object b=B.create();
^
1 error
:(
ERROR MESSAGES/STACK TRACES THAT OCCUR :
... reference to create is ambiguous, both method create() in A and method <T>create() in B match
Object b=B.create();
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class A {
public static Object create() {
return null;
}
}
class B extends A {
public static<T> Object create() {
return null;
}
public static void main(String... args) {
Object b=B.create();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
- do not hide static methods with different type parameter specifications. (Use other method name)... But this makes my code more difficult to use because a more complex coding pattern must be followed. :(
- relates to
-
JDK-5081782 type arguments to non-generic methods
-
- Closed
-
-
JDK-6561376 Use actual type arguments to choose most specific method
-
- Closed
-