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

[macos] Exception when input emoji using Chinese input method

    XMLWordPrintable

    Details

      Backports

        Description

        ADDITIONAL SYSTEM INFORMATION :
        OS:
        macOs Big Sur, 11.0.1

        java version:
        openjdk version "15" 2020-09-15
        OpenJDK Runtime Environment Zulu15.27+17-CA (build 15+36)
        OpenJDK 64-Bit Server VM Zulu15.27+17-CA (build 15+36, mixed mode, sharing)

        openjfx version:
        15.0.1

        A DESCRIPTION OF THE PROBLEM :
        Input any emoji using Chinese input method in JavaFX text area, an exception is thrown:

        Exception in thread "JavaFX Application Thread" java.lang.StringIndexOutOfBoundsException: begin 0, end 2, length 1
        at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3734)
        at java.base/java.lang.String.substring(String.java:1903)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleInputMethodEvent$7(GlassViewEventHandler.java:647)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleInputMethodEvent$8(GlassViewEventHandler.java:640)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleInputMethodEvent(GlassViewEventHandler.java:639)
        at javafx.graphics/com.sun.glass.ui.View.handleInputMethodEvent(View.java:648)
        at javafx.graphics/com.sun.glass.ui.View.notifyInputMethod(View.java:977)
        at javafx.graphics/com.sun.glass.ui.mac.MacView.notifyInputMethodMac(MacView.java:161)

        Seems that the notify str only contains the first byte of UTF-8 encoded emoji bytes.

        Copy & Paste a emoji to text field works fine.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. Create a simple JavaFX app with a TextArea, and Run:

        public class Test extends Application {

            @Override
            public void start(Stage stage) {
                stage.setTitle("Test");
                var text = new TextArea();
                var scene = new Scene(text, 600, 400);
                stage.setScene(scene);
                stage.show();
            }

            public static void main(String[] args) {
                launch(args);
            }
        }

        2. Input text using ‘简体拼音’ or any other Chinese input method, for example, keys 'keai' and then select the emoji in the candidate words.


          Attachments

            Issue Links

              Activity

                People

                Assignee:
                kcr Kevin Rushforth
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: