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

javac mishandles supplementary character in character literal

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Windows 11 not 10 but saw no option for 11 so picked 10.

      A DESCRIPTION OF THE PROBLEM :
      In Java 24 (build 24+36-3646), the method `Character.isEmoji(int)` returns incorrect results.

      Example test code:

      public class EmojiTest {
          public static void main(String[] args) {
              System.out.println("'😊' -> " + Character.isEmoji('😊')); // Expected: true
              System.out.println("'1' -> " + Character.isEmoji('1')); // Expected: false
              System.out.println("'H' -> " + Character.isEmoji('H')); // Expected: false
          }
      }

      Observed output:
      '😊' -> false
      '1' -> true
      'H' -> false

      Expected output:
      '😊' -> true
      '1' -> false
      'H' -> false

      System details:
      java.version = 24
      build = 24+36-3646
      vendor = Oracle Corporation

      I also am getting a warning from my IDE telling me that the smiling face emoji is too long but it still compiles. But the main issue is that the isEmoji method seems to have some issues.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the code with Java 24.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      '😊' -> true
      '1' -> false
      'H' -> false
      ACTUAL -
      '😊' -> false
      '1' -> true
      'H' -> false

      ---------- BEGIN SOURCE ----------
      public class EmojiTest {
          public static void main(String[] args) {
              System.out.println("'😊' -> " + Character.isEmoji('😊')); // Expected: true
              System.out.println("'1' -> " + Character.isEmoji('1')); // Expected: false
              System.out.println("'H' -> " + Character.isEmoji('H')); // Expected: false
          }
      }
      ---------- END SOURCE ----------

            jlahoda Jan Lahoda
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: