-
Bug
-
Resolution: Fixed
-
P3
-
5.0
The following illustrates that the binary compatibility rules conflict
with generics. The method resolved at compile time and at runtime are
different, resulting in a runtime call to the wrong method.
Date: Wed, 25 Feb 2004 14:15:59 -0800
From: <###@###.###>
Subject: Method isn't hidden, but acts like it is at runtime
To: ###@###.###
Cc: ###@###.###
import java.util.*;
import static java.lang.System.out;
public class T2 {
public static void main(String[] args) {
Collection c = T2a.m(new ArrayList<String>()); // => "T2a.m"
}
static Collection m(List<String> p) {
out.println("T2.m");
return null;
}
}
class T2a extends T2 {
static Collection m(List<Number> p) {
out.println("T2a.m");
return null;
}
}
with generics. The method resolved at compile time and at runtime are
different, resulting in a runtime call to the wrong method.
Date: Wed, 25 Feb 2004 14:15:59 -0800
From: <###@###.###>
Subject: Method isn't hidden, but acts like it is at runtime
To: ###@###.###
Cc: ###@###.###
import java.util.*;
import static java.lang.System.out;
public class T2 {
public static void main(String[] args) {
Collection c = T2a.m(new ArrayList<String>()); // => "T2a.m"
}
static Collection m(List<String> p) {
out.println("T2.m");
return null;
}
}
class T2a extends T2 {
static Collection m(List<Number> p) {
out.println("T2a.m");
return null;
}
}
- duplicates
-
JDK-5005072 binary compatibility rules cause wrong method to be called!
- Closed
- relates to
-
JDK-6388596 generics: erasure name clash
- Closed
-
JDK-6910491 Hiding of non-generic static method by generic static method
- Open