-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.4.0
-
generic, sparc
-
generic, solaris_2.6
Name: ooR10001 Date: 07/05/2000
Overloading getTime() method in java.sql.Timestamp class in jdk 1.4 causes
compatibility problem in serialization because writeObject() method in
base class java.util.Date use method getTime() when putting data into a
stream.
In jdk older then 1.4 method getTime is invoked from a superclass of Timestamp,
in jdk 1.4 overloaded method getTime() is invoked and returned value differs
from older jdks.
Due to that, a stream for superclass in jdk1.4 is different from the
corresponding stream in older jdks - it is a compatibility problem. This change
was not approved by the CCC.
getTime() method in jdk 1.4:
public long getTime() {
long time = super.getTime();
return (time + (nanos / 1000000));
}
------------------------------------------
test example to reproduce a bug:
import java.sql.Timestamp;
class T extends Timestamp {
T(long t) {
super(t);
}
public long getSuperTime() {
return getTime() - getNanos() / 1000000;
}
}
public class t {
public static void main(String[] args) {
T stamp = new T(123L);
if (stamp.getTime() == stamp.getSuperTime()) {
System.out.println("Test PASSED");
} else {
System.out.println("Test FAILED");
}
}
}
---------------------------------
Test output:
Test FAILED
----------------------------------
======================================================================
- duplicates
-
JDK-4352300 jck_regr: api/java_sql/serialization/descriptions.html#Timestamp
- Closed