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

java.awt.font.NumericShaper violates equals/hashCode contract

XMLWordPrintable

    • 2d
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      I get two NumericShapers, they are equal, but have different hashCode.


      ---------- BEGIN SOURCE ----------
      import java.awt.font.NumericShaper;
      import java.util.EnumSet;
      import static java.awt.font.NumericShaper.*;

      public class EqualsTest {
          public static void main(String[] args) {
              NumericShaper ns1 = getContextualShaper(ARABIC | TAMIL, TAMIL);
              NumericShaper ns2 = getContextualShaper(
                                      EnumSet.of(Range.ARABIC, Range.TAMIL),
                                      Range.TAMIL);

              if (ns1.equals(ns2) && ns1.hashCode() != ns2.hashCode()) {
                  throw new RuntimeException("ns1 and ns2 have different hash codes: "
                      + ns1.hashCode() + " vs " + ns2.hashCode());
              }

          }
      }

      ---------- END SOURCE ----------

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: