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

Character.isDefined method doesn't comply with the specs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.0
    • core-libs
    • beta
    • sparc
    • solaris_2.5
    • Verified



      Name: saC57035 Date: 05/26/98


      The specification for the isDefined method says:

      "A character is defined if at least one of the following is true:
        - It has an entry in the Unicode attribute table.
        - Its value is in the range '\u3040' .. '\u9FA5'.
        - Its value is in the range '\uF900' .. '\uFA2D'. "

      A minor nit is that there is an obvious typo here:
      '\u3040' should be read as '\u3400'.

      It is more serious problem that the contract about the first range of
      values is not implemented. It looks like only the existence of
      the table entry is taken into account.

      Here is the example demonstrating the bug:
      ------------------------------------------
      public class CharTest {

        public static void main(String args[]) {
          char trueChars[] = {
            '\u3400', '\u3401', '\u3800', '\u4000',
            '\u4800', '\u5000', '\u6000', '\u7000',
            '\u8000', '\u9000', '\u9FA4', '\u9FA5'
          };
          int failures=0;
          for (int i=0;i<trueChars.length;i++) {
            if ( ! Character.isDefined(trueChars[i]) ) {
              System.out.println ("isDefined(\\u"+
                Integer.toHexString(trueChars[i]).toUpperCase()+"): true expected.");
              ++failures;
            }
          }
          if (failures == 0)
            System.out.println("Test passed");
        }

      }
      ---- Output -------------------
      isDefined(\u3400): true expected.
      isDefined(\u3401): true expected.
      isDefined(\u3800): true expected.
      isDefined(\u4000): true expected.
      isDefined(\u4800): true expected.
      ---------------------------------------------

      If this behaviour is intended, the specs should be updated
      to reflect that.

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

            joconnersunw John Oconner (Inactive)
            savzan Stanislav Avzan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: