FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Following code should not compile:
class x {
int f(List<String> l) {return 0;}
double f(List<Integer> l) {return 0;}
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Following code should not compile:
class x {
int f(List<String> l) {return 0;}
double f(List<Integer> l) {return 0;}
}
since both method have the same erasure.
JLS3 draft 8.4.8.3 says, it is error if there are two methods m1 and m2 in a class such that:
- m1 and m2 have the same name
- m2 is accessible
- the signature of m1 is not subsignature if m2
- both methods have same erasure
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Error: line (4) name clash: f(java.util.List<java.lang.String>) and f(java.util.List<java.lang.Integer>) have the same erasure
ACTUAL -
no error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.List;
class x {
int f(List<String> l) {return 0;}
double f(List<Integer> l) {return 0;}
}
---------- END SOURCE ----------
###@###.### 10/21/04 23:19 GMT
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Following code should not compile:
class x {
int f(List<String> l) {return 0;}
double f(List<Integer> l) {return 0;}
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Following code should not compile:
class x {
int f(List<String> l) {return 0;}
double f(List<Integer> l) {return 0;}
}
since both method have the same erasure.
JLS3 draft 8.4.8.3 says, it is error if there are two methods m1 and m2 in a class such that:
- m1 and m2 have the same name
- m2 is accessible
- the signature of m1 is not subsignature if m2
- both methods have same erasure
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Error: line (4) name clash: f(java.util.List<java.lang.String>) and f(java.util.List<java.lang.Integer>) have the same erasure
ACTUAL -
no error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.List;
class x {
int f(List<String> l) {return 0;}
double f(List<Integer> l) {return 0;}
}
---------- END SOURCE ----------
###@###.### 10/21/04 23:19 GMT
- duplicates
-
JDK-6979815 Compiler accepts 2 methods with override-equivalent signatures
-
- Closed
-
- relates to
-
JDK-2191179 javac 1.5.0_17 fails with incorrect error message
-
- Closed
-
-
JDK-6730568 Type erasure affects return types + type parameters
-
- Closed
-
-
JDK-2171460 javadoc does not get compilation errors after type erasure
-
- Closed
-