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

AccessibleRelationSet allows multiple relations with the same key

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • client-libs
    • None
    • merlin
    • x86
    • windows_nt
    • Not verified

      jethro@eng 17Apr2000

      Run the following program (i.e., 'java AccessibleRelationSetTest'), and you
      should see two errors:

          ERROR: Duplicate relation added
          ERROR: More than one LABEL_FOR relation in set

      The documentation is not clear on this point, but after talking with Lynn
      Monsanto, I believe that each relation set should have only one relation
      with a given key. I think that the implementation should automatically merge
      the arrays when multiple relations are added with the same key. I'll file
      a separate doc. bug.

      // AccessibleRelationSetTest.java
      import javax.accessibility.AccessibleRelation;
      import javax.accessibility.AccessibleRelationSet;

      public class AccessibleRelationSetTest {
           public static void main(String args[]) {
      boolean errorOccurred = false;
      Integer target1 = new Integer(0);
      Integer target2 = new Integer(0);
               AccessibleRelationSet set = new AccessibleRelationSet();
      AccessibleRelation relation = null;
      boolean added = false;

      // Legal
      relation =
      new AccessibleRelation(AccessibleRelation.LABEL_FOR, target1);
      added = set.add(relation);

      // Not legal
      relation =
      new AccessibleRelation(AccessibleRelation.LABEL_FOR, target1);
      added = set.add(relation);
      if (added) {
      System.err.println("ERROR: Duplicate relation added");
      errorOccurred = true;
      }

      // Legal, but should not cause more than one LABEL_FOR relation
      relation =
      new AccessibleRelation(AccessibleRelation.LABEL_FOR, target2);
      added = set.add(relation);
      if (!added) {
      System.err.println("ERROR: legal relation rejected");
      errorOccurred = true;
      }

      // See if there is more than one LABEL_FOR relation
      AccessibleRelation[] finalSet = set.toArray();
      int labelForCount = 0;
      for (int i = 0; i < finalSet.length; ++i) {
      if (finalSet[i].getKey().equals(AccessibleRelation.LABEL_FOR)) {
      ++labelForCount;
      }
      }
      if (labelForCount > 1) {
      System.err.println("ERROR: More than one LABEL_FOR relation in set");
      errorOccurred = true;
      }

      if (errorOccurred) {
      throw new Error(
      "AccessibleRelationSet behavior did not match specifications");
      }
           }
      } // class AccessibleRelationSetTest

            lmonsantsunw Lynn Monsanto (Inactive)
            jdunnsunw Jeffrey Dunn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: