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

Character.isLetterOrDigit() does not match the spec

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.0
    • core-libs
    • None
    • beta
    • generic
    • generic

      The method Character.isLetterOrDigit() does not match the spec.

      The spec says that \u1FFF and \u3040 will return true as being either a char or a digit. The current code returns false.

      Here is a test case to reproduce the bug
      to run put /net/castor.east/jtg/testbase/src/modena_jlib2_2/classes in your classpath

      /*
       * JLIB++ : The Modena JLIB++ Suite, Version 2.2, June 1998
       * Copyright (c) 1995-1998 Modena Software (I) Pvt. Ltd., All Rights Reserved
       */

      /*
       * Section : 20.5.16
       * FileName : c2005161.java
       * Purpose : Positive test for 20.5.16
       *
       * public static boolean isLetterOrDigit(char ch)
       * The result is true if and only if the character argument is a letter - or
       * digit. A character is a considered to be letter-or-digit if and only if
       * it is a defined Unicode character and its code lies in one of the following
       * ranges:
       * 0030-0039
       * 0041-005A
       * 0061-007A
       * 00C0-00D6
       * 00D8-00F6
       * 00F8-00FF
       * 0100-1FFF
       * 3040-9FFF
       * F900-FDFF
       * FE70-FEFE
       * FF10-FF19
       * FF21-FF3A
       * FF41-FF5A
       * FF66-FFDC
       *
       */

       import cpack.Chk;
       
       class X
       {
         public void check_isLetterOrDigit()
         {
           boolean bool ;
           char ch1 = '\u0030';
           char ch2 = '\u0039';
           char ch3 = '\u0041';
           char ch4 = '\u005A';
           char ch5 = '\u0061';
           char ch6 = '\u007A';
           char ch7 = '\u00C0';
           char ch8 = '\u00D6';
           char ch9 = '\u00D8';
           char ch10 = '\u00F6';
           char ch11 = '\u00F8';
           char ch12 = '\u00FF';
           char ch13 = '\u0100';
           char ch14 = '\u1FFF';
           char ch15 = '\u3040';
           
           //will fail if the method has not been implemented
           
           bool = Character.isLetterOrDigit(ch1);
           Chk.chkBooleanVal("err_1","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch2);
           Chk.chkBooleanVal("err_2","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch3);
           Chk.chkBooleanVal("err_3","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch4);
           Chk.chkBooleanVal("err_4","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch5);
           Chk.chkBooleanVal("err_5","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch6);
           Chk.chkBooleanVal("err_6","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch7);
           Chk.chkBooleanVal("err_7","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch8);
           Chk.chkBooleanVal("err_8","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch9);
           Chk.chkBooleanVal("err_9","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch10);
           Chk.chkBooleanVal("err_10","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch11);
           Chk.chkBooleanVal("err_11","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch12);
           Chk.chkBooleanVal("err_12","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch13);
           Chk.chkBooleanVal("err_13","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch14);
           Chk.chkBooleanVal("err_14","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch15);
           Chk.chkBooleanVal("err_15","bool",bool,true);
           
         }
           
         
        public static void main(String arg[])
        {
           X ox = new X();
            
           ox.check_isLetterOrDigit();
           Chk.endTest("c2005161");
        }
      }


      chrys.rowe@East 1999-02-24

      The unicode chars \uFDFF and \uFEFE are also incorrect.

      Here is a test case for them

      /*
       * JLIB++ : The Modena JLIB++ Suite, Version 2.2, June 1998
       * Copyright (c) 1995-1998 Modena Software (I) Pvt. Ltd., All Rights Reserved
       */

      /*
       * Section : 20.5.16
       * FileName : c2005162.java
       * Purpose : Positive test for 20.5.16
       *
       * public static boolean isLetterOrDigit(char ch)
       * The result is true if and only if the character argument is a letter - or
       * digit. A character is a considered to be letter-or-digit if and only if
       * it is a defined Unicode character and its code lies in one of the following
       * ranges:
       * 0030-0039
       * 0041-005A
       * 0061-007A
       * 00C0-00D6
       * 00D8-00F6
       * 00F8-00FF
       * 0100-1FFF
       * 3040-9FFF
       * F900-FDFF
       * FE70-FEFE
       * FF10-FF19
       * FF21-FF3A
       * FF41-FF5A
       * FF66-FFDC
       *
       */

       import cpack.Chk;
       
       class X
       {
         public void check_isLetterOrDigit()
         {
           boolean bool ;
           char ch0 = '\u9FFF';
           char ch1 = '\uF900';
           char ch2 = '\uFDFF';
           char ch3 = '\uFE70';
           char ch4 = '\uFEFE';
           char ch5 = '\uFF10';
           char ch6 = '\uFF19';
           char ch7 = '\uFF21';
           char ch8 = '\uFF3A';
           char ch9 = '\uFF41';
           char ch10 = '\uFF5A';
           char ch11 = '\uFF66';
           char ch12 = '\uFFDC';
           char ch13 = '\u0020';
           
           //will fail if the method has not been implemented
           
           bool = Character.isLetterOrDigit(ch1);
           Chk.chkBooleanVal("err_1","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch2);
           Chk.chkBooleanVal("err_2","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch3);
           Chk.chkBooleanVal("err_3","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch4);
           Chk.chkBooleanVal("err_4","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch5);
           Chk.chkBooleanVal("err_5","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch6);
           Chk.chkBooleanVal("err_6","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch7);
           Chk.chkBooleanVal("err_7","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch8);
           Chk.chkBooleanVal("err_8","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch9);
           Chk.chkBooleanVal("err_9","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch10);
           Chk.chkBooleanVal("err_10","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch11);
           Chk.chkBooleanVal("err_11","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch12);
           Chk.chkBooleanVal("err_12","bool",bool,true);
           
           bool = Character.isLetterOrDigit(ch13);
           Chk.chkBooleanVal("err_13","bool",bool,false);
         }
           
         
        public static void main(String arg[])
        {
           X ox = new X();
            
           ox.check_isLetterOrDigit();
           Chk.endTest("c2005162");
        }
      }

            joconnersunw John Oconner (Inactive)
            chrowe Chrys Rowe (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: