-
Bug
-
Resolution: Cannot Reproduce
-
P5
-
None
-
6
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.6.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta-b59g)
Java HotSpot(TM) Client VM (build 1.6.0-beta-b59g, mixed mode, sharing)
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pxi32dev-20051104)
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Linux x86-32 j9vmxi3223-20051103 (JIT enabled)
J9VM - 20051027_03723_lHdSMR
JIT - 20051027_1437_r8
GC - 20051020_AA)
JCL - 20051102
ADDITIONAL OS VERSION INFORMATION :
Debian GNU/Linux Sarge 2.6.8 i686
A DESCRIPTION OF THE PROBLEM :
In the described case 'javac' either reports an erasure name clash error or compiles silently according to whether all classes are compiled at once or one after the other.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
(1) Create 'Fooable.java', 'Foo.java' and 'Bar.java' as given in a common working directory.
(2) Delete all class files in the working directory.
(3) Execute 'javac Bar.java'.
(4) Delete all class files in the working directory.
(5) Execute 'javac Foo.java' followed by 'javac Bar.java'.
(6) Execute 'java Bar'.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Steps (3) and (5) are expected to give the same result, i.e. a working 'Bar.class'.
ACTUAL -
Step (3) results in an erasure name clash error report.
Step (5) processes fine and (6) prints 'false' as expected.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Bar.java:1: name clash: equals(T) in Fooable<Bar> and equals(java.lang.Object) in java.lang.Object have the same erasure, yet neither overrides the other
public class Bar extends Foo<Bar> {
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
//Fooable.java
public interface Fooable<T> {
public boolean equals(T t);
}
//Foo.java
public class Foo<T extends Foo<T>> implements Fooable<T> {
public boolean equals(T t) {
return false;
}
}
//Bar.java
public class Bar extends Foo<Bar> {
public static void main(String[] args) {
Bar a = new Bar();
Bar b = new Bar();
System.out.println(a.equals(b));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Compile stepwise.
java version "1.6.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta-b59g)
Java HotSpot(TM) Client VM (build 1.6.0-beta-b59g, mixed mode, sharing)
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pxi32dev-20051104)
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Linux x86-32 j9vmxi3223-20051103 (JIT enabled)
J9VM - 20051027_03723_lHdSMR
JIT - 20051027_1437_r8
GC - 20051020_AA)
JCL - 20051102
ADDITIONAL OS VERSION INFORMATION :
Debian GNU/Linux Sarge 2.6.8 i686
A DESCRIPTION OF THE PROBLEM :
In the described case 'javac' either reports an erasure name clash error or compiles silently according to whether all classes are compiled at once or one after the other.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
(1) Create 'Fooable.java', 'Foo.java' and 'Bar.java' as given in a common working directory.
(2) Delete all class files in the working directory.
(3) Execute 'javac Bar.java'.
(4) Delete all class files in the working directory.
(5) Execute 'javac Foo.java' followed by 'javac Bar.java'.
(6) Execute 'java Bar'.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Steps (3) and (5) are expected to give the same result, i.e. a working 'Bar.class'.
ACTUAL -
Step (3) results in an erasure name clash error report.
Step (5) processes fine and (6) prints 'false' as expected.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Bar.java:1: name clash: equals(T) in Fooable<Bar> and equals(java.lang.Object) in java.lang.Object have the same erasure, yet neither overrides the other
public class Bar extends Foo<Bar> {
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
//Fooable.java
public interface Fooable<T> {
public boolean equals(T t);
}
//Foo.java
public class Foo<T extends Foo<T>> implements Fooable<T> {
public boolean equals(T t) {
return false;
}
}
//Bar.java
public class Bar extends Foo<Bar> {
public static void main(String[] args) {
Bar a = new Bar();
Bar b = new Bar();
System.out.println(a.equals(b));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Compile stepwise.
- relates to
-
JDK-5009937 hiding versus generics versus binary compatibility
- Closed