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

java.text.DateFormat.equals(null) throws NullPointerException

XMLWordPrintable

    • 1.1.6
    • sparc
    • solaris_2.5
    • Verified



        Name: dfC67450 Date: 12/03/97



        The java.text.DateFormat.equals(Object) method does not work correctly.
        This method should return false if called with null argument
        (see general contract for equals(): JLS 1.0 item 20.1.3, page 459).
        But it throws NullPointerException.


        Here is the test demonstrating the bug:

        -----------------TestDE.java------------------------
        import java.util.*;
        import java.text.*;
        public class TestDE {
            public static void main (String args[]){
               DateFormatTest dtf = new DateFormatTest();
               System.out.println(dtf.equals(null));
            }
        }

        class DateFormatTest extends DateFormat {
            public Date parse(String text, ParsePosition parsePosition) {
              return null;
            }
            public StringBuffer format(Date date,
                                StringBuffer toAppendTo,
                                FieldPosition pos)
            {
              return null;
            }
        }
        ---------Output from the test---------------------
        java.lang.NullPointerException
                at java.text.DateFormat.equals(DateFormat.java)
                at TestDE.main(TestPZ.java:6)
        -------------------------------------------------

        ======================================================================

              joconnersunw John Oconner (Inactive)
              dfazunensunw Dmitri Fazunenko (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: