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

sun.font.CharSequenceCodePointIterator is buggy and unused

XMLWordPrintable

    • 2d
    • b22

      The class sun.font.CharSequenceCodePointIterator is not used anywhere in the JDK.

      Also it has (at least) one bug which would
      cause an exception if a hi surrogate were the last char

          public int next() {
              if (index < text.length()) {
                  char cp1 = text.charAt(index++);
                  if (Character.isHighSurrogate(cp1) && index < text.length()) {
                      char cp2 = text.charAt(index+1); /// <<< Should not be "+1"
                      if (Character.isLowSurrogate(cp2)) {
                          ++index;
                          return Character.toCodePoint(cp1, cp2);
                      }
                  }
                  return cp1;
              }
              return DONE;
          }

      We could fix it, but it wouldn't help anyone and it would be hard to test.
      It might be best to just delete the class.

      Since we've not needed it in 2 decades I doubt we'll ever need it.

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

              Created:
              Updated:
              Resolved: