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

Incorrect processing of supplementary-plane characters in text fields

XMLWordPrintable

    • 2d
    • b96
    • 9
    • b158
    • generic
    • generic

        FULL PRODUCT VERSION :
        java version "9-ea"
        Java(TM) SE Runtime Environment (build 9-ea+152)
        Java HotSpot(TM) 64-Bit Server VM (build 9-ea+152, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows [Version 10.0.14393]

        A DESCRIPTION OF THE PROBLEM :
         Supplementary-plane characters in text fields are sometimes treated as two characters - it must be caused by their internal representation as surrogate pairs.

        REGRESSION. Last worked in version 8u112

        ADDITIONAL REGRESSION INFORMATION:
        java version "1.8.0_112"
        Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
        Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run sample program given below. In opened text field, press Left first, then Backspace.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        First character is deleted (completely), second remains.
        ACTUAL -
        First character is replaced with some undisplayable character, probably because only a part of surrogate pair was deleted.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import javax.swing.*;

        public class JTextFieldTest {
            public static void main(String[] args) {
                SwingUtilities.invokeLater(() -> {
                    JFrame frame = new JFrame();
                    JTextField field = new JTextField(20);
                    field.setText(new String(new int[]{0x1d400, 0x61}, 0, 2));
                    frame.add(field);
                    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                });
            }
        }

        ---------- END SOURCE ----------

              prr Philip Race
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: