Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5103041

Regression: binary compatibility problem with java.sql.Timestamp.compareTo

XMLWordPrintable

    • rc
    • 5.0
    • b59
    • generic, x86
    • generic, linux, windows_xp
    • Verified

        Just to make this concrete, here's a small program demonstrating the
        problem. Compile and run it, first against 1.4.2, then against
        1.5/5.0:

        import java.sql.Timestamp;
        import java.util.Date;

        public class Foo {
          public static void main(String[] args) {
            Date d = new Date();
            Timestamp ts = new Timestamp(d.getTime());
            System.out.println(ts.compareTo(d));
          }
        }

        Note that this a *binary compatibility problem*!! The overload
        resolution is the same in 1.4.2 and 1.5.0; in either case, it's
        compareTo(Date). With a 1.4.2 runtime, it dispatches to the version
        defined in java.util.Date, with a 1.5.0 runtime it dispatches to the
        version defined in java.sql.Timestamp, which promptly casts its
        argument to Timestamp (and blows up). This really feels like a P2 bug
        to me.

              ahandasunw Amit Handa (Inactive)
              ahe Peter Ahe
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: