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

Character.isJavaIdentifierStart(int) false positive?

XMLWordPrintable

    • b04
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      jdk-11.0.21+8-34-g70862e011b



      openjdk version "11.0.22-internal" 2024-01-16
      OpenJDK Runtime Environment (build 11.0.22-internal+0-adhoc.root.jdk11u-dev)
      OpenJDK 64-Bit Server VM (build 11.0.22-internal+0-adhoc.root.jdk11u-dev, mixed mode)



      A DESCRIPTION OF THE PROBLEM :
      I found that the jdk11-dev version triggered Character.isJavaIdentifierStart(int) failed for codepoint 9feb when executing Character.isJavaIdentifierStart(cp). I wrote a script, tested the stable versions of 17 and 11, and did not get any results. I do not quite understand why this version would consider Character.isJavaIdentifierStart(40939)=true.



      ACTUAL -
      Exception in thread "main" java.lang.RuntimeException: Character.isJavaIdentifierStart(int) failed for codepoint 9feb
              at test.testIsJavaIdentifierStart_int(test.java:12)
              at test.main(test.java:18)

      ---------- BEGIN SOURCE ----------
      public class test {
          static int JAPANESE_ERA_CODEPOINT = 0x32FF;

          void testIsJavaIdentifierStart_int() throws Exception {
              for (int cp = 0; cp <= Character.MAX_CODE_POINT; cp++) {
                  boolean expected = false;
                  if (cp != JAPANESE_ERA_CODEPOINT) {
                      byte type = (byte) Character.getType(cp);
                      expected = Character.isLetter(cp) || type == Character.LETTER_NUMBER || type == Character.CURRENCY_SYMBOL || type == Character.CONNECTOR_PUNCTUATION;
                  }
                  if (Character.isJavaIdentifierStart(cp) != expected) {
                      throw new RuntimeException("Character.isJavaIdentifierStart(int) failed for codepoint " + Integer.toHexString(cp));
                  }
              }
          }

          public static void main(String[] args) throws Exception {
              new test().testIsJavaIdentifierStart_int();
          }
      }
      ---------- END SOURCE ----------

        1. Two.png
          Two.png
          122 kB
        2. Three.png
          Three.png
          69 kB
        3. One.png
          One.png
          129 kB
        4. Main.java
          0.7 kB
        5. Four.png
          Four.png
          51 kB

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: