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

Bidi.requiresBidi has misleading exception message

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 16
    • None
    • core-libs
    • None
    • b22

      jshell> Bidi.requiresBidi("AAAAAAAAA".toCharArray(), 2,20)
      | Exception java.lang.IllegalArgumentException: Value start 2 is out of range 0 to 20
      | at BidiBase.requiresBidi (BidiBase.java:4543)
      | at Bidi.requiresBidi (Bidi.java:304)
      | at (#2:1)

      The emitted statement "Value start 2 is out of range 0 to 20" is false.
      The exception message is created here [1] and is based on more than the simple size check. This leads to the incorrect message.

      4542 if (0 > start || start > limit || limit > text.length) {
      4543 throw new IllegalArgumentException("Value start " + start +
      4544 " is out of range 0 to " + limit);
      4545 }

      [1] https://java.se.oracle.com/source/xref/jdk-jdk/open/src/java.base/share/classes/jdk/internal/icu/text/BidiBase.java#4542

            naoto Naoto Sato
            mschoene Marc Schönefeld
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: