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

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

XMLWordPrintable

    • 1.1.6
    • sparc
    • solaris_2.5
    • Verified



        Name: mgC56079 Date: 09/15/97



        java.text.RuleBasedCollator.equals(null) throws NullPointerException.
        Should return false.

        --- Here is the general contract of equals() (see JLS, 20.1.3) ----
        20.1.3 public boolean equals(Object obj)

        This method indicates whether some other object is "equal to" this one.

        The general contract of equals is that it implements an equivalence relation:

              It is reflexive: for any reference value x, x.equals(x) should return true.
              It is symmetric: for any reference values x and y, x.equals(y) should return
              true if and only if y.equals(x) returns true.
              It is transitive: for any reference values x, y, and z, if x.equals(y) returns
              true and y.equals(z) returns true, then x.equals(z) should return true.
              It is consistent: for any reference values x and y, multiple invocations of
              x.equals(y) consistently return true or consistently return false, provided
              no information used by x and y in equals comparisons is modified.
              For any non-null reference value x, x.equals(null) should return false.
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ---------Here is the test demonstrating the bug (RBC.java) --------------
        import java.text.*;

        public class RBC {

        public static void main(String args[]) {

          try {
            RuleBasedCollator rbc=new RuleBasedCollator("< a < b");
            System.out.println(rbc.equals(null));
          }
          catch (ParseException e) {
            System.out.println(e);
          }

        }

        }
        ---------Output from the test---------------------
        % java RBC
        java.lang.NullPointerException
        at java.text.Collator.equals(Collator.java:407)
        at java.text.RuleBasedCollator.equals(RuleBasedCollator.java:485)
        at RBC.main(RBC.java:9)
        --------------------------------------------------

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

              bcbeck Brian Beck (Inactive)
              mgorshen Mikhail Gorshenev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: