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

Label: long unicode text issue

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: None
    • Component/s: javafx
    • Environment:

      Win7, b66

      Description

      Got ArrayIndexOutOfBoundsException for following sample:

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class FXRenderer extends Application {

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

          @Override
          public void start(Stage stage) throws Exception {
              StringBuilder builder = new StringBuilder();
              for (int character = Character.MIN_CODE_POINT; character < Character.MAX_CODE_POINT; character++) {
                  char[] chars = Character.toChars(character);
                  builder.append(chars);
              }
              HBox pane = new HBox();
              //Label text = new Label(builder.toString().substring(0, 10000));
              Label text = new Label(builder.toString());
              text.setWrapText(true);
              pane.getChildren().add(text);
              Scene scene = new Scene(pane, 1024, 1024);
              stage.setScene(scene);
              stage.show();
          }
      }

      Exception in Application start method
      Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
              at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:376)
              at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
              at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
              at java.lang.Thread.run(Thread.java:662)
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 4308762
              at com.sun.javafx.text.TextRun.getWrapIndex(TextRun.java:191)
              at com.sun.javafx.text.TextLayout.layout(TextLayout.java:504)
              at com.sun.javafx.sg.prism.NGTextHelper.buildTextLines(NGTextHelper.java:1065)
              at com.sun.javafx.sg.prism.NGTextHelper.validateText(NGTextHelper.java:983)
              at com.sun.javafx.sg.prism.NGTextHelper.computeBoundsLogical(NGTextHelper.java:395)
              at com.sun.javafx.sg.prism.NGTextHelper.computeLayoutBounds(NGTextHelper.java:354)
              at javafx.scene.text.Text.impl_computeLayoutBoundsInt(Text.java:1217)
              at javafx.scene.text.Text.impl_computeLayoutBounds(Text.java:1233)
              at javafx.scene.Node$16.computeBounds(Node.java:2875)
              at javafx.scene.Node$LazyBoundsProperty.get(Node.java:7662)
              at javafx.scene.Node$LazyBoundsProperty.get(Node.java:7632)
              at javafx.scene.Node.getLayoutBounds(Node.java:2890)
              at com.sun.javafx.scene.control.skin.Utils.computeTextHeight(Utils.java:70)
              at com.sun.javafx.scene.control.skin.LabeledSkinBase.computePrefHeight(LabeledSkinBase.java:783)
              at javafx.scene.control.Control.computePrefHeight(Control.java:449)
              at javafx.scene.Parent.prefHeight(Parent.java:878)
              at javafx.scene.layout.Region.prefHeight(Region.java:1170)
              at com.sun.javafx.scene.control.skin.LabeledSkinBase.computeMaxHeight(LabeledSkinBase.java:805)
              at javafx.scene.control.Control.computeMaxHeight(Control.java:429)
              at javafx.scene.layout.Region.maxHeight(Region.java:1204)
              at javafx.scene.layout.Region.layoutInArea(Region.java:1806)
              at javafx.scene.layout.Region.layoutInArea(Region.java:1768)
              at javafx.scene.layout.HBox.layoutChildren(HBox.java:529)
              at javafx.scene.Parent.layout(Parent.java:1012)
              at javafx.scene.Scene.layoutDirtyRoots(Scene.java:517)
              at javafx.scene.Scene.doLayoutPass(Scene.java:488)
              at javafx.scene.Scene.preferredSize(Scene.java:1496)
              at javafx.scene.Scene.impl_preferredSize(Scene.java:1523)
              at javafx.stage.Window$10.invalidated(Window.java:723)
              at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:106)
              at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:140)
              at javafx.stage.Window.setShowing(Window.java:786)
              at javafx.stage.Window.show(Window.java:801)
              at javafx.stage.Stage.show(Stage.java:230)
              at main.FXRenderer.start(FXRenderer.java:33)
              at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
              at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:207)
              at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
              at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
              at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
              at com.sun.glass.ui.win.WinApplication$3$1.run(Unknown Source)
              ... 1 more
      Java Result: 1

      Even limited (first 10000 symbols) sequence makes the window unresponsive. An attempt to resize it may also leads to ArrayIndexOutOfBoundsException:

      java.lang.ArrayIndexOutOfBoundsException: 64
              at com.sun.javafx.text.TextRun.getWrapIndex(TextRun.java:191)
              at com.sun.javafx.text.TextLayout.layout(TextLayout.java:504)
              at com.sun.javafx.sg.prism.NGTextHelper.buildTextLines(NGTextHelper.java:1065)
              at com.sun.javafx.sg.prism.NGTextHelper.validateText(NGTextHelper.java:983)
              at com.sun.javafx.sg.prism.NGTextHelper.computeBoundsLogical(NGTextHelper.java:395)
              at com.sun.javafx.sg.prism.NGTextHelper.computeLayoutBounds(NGTextHelper.java:354)
              at javafx.scene.text.Text.impl_computeLayoutBoundsInt(Text.java:1217)
              at javafx.scene.text.Text.impl_computeLayoutBounds(Text.java:1233)
              at javafx.scene.Node$16.computeBounds(Node.java:2875)
              at javafx.scene.Node$LazyBoundsProperty.get(Node.java:7662)
              at javafx.scene.Node$LazyBoundsProperty.get(Node.java:7632)
              at javafx.scene.Node.getLayoutBounds(Node.java:2890)
              at com.sun.javafx.scene.control.skin.Utils.computeTextHeight(Utils.java:70)
              at com.sun.javafx.scene.control.skin.LabeledSkinBase.computePrefHeight(LabeledSkinBase.java:783)
              at javafx.scene.control.Control.computePrefHeight(Control.java:449)
              at javafx.scene.Parent.prefHeight(Parent.java:878)
              at javafx.scene.layout.Region.prefHeight(Region.java:1170)
              at com.sun.javafx.scene.control.skin.LabeledSkinBase.computeMaxHeight(LabeledSkinBase.java:805)
              at javafx.scene.control.Control.computeMaxHeight(Control.java:429)
              at javafx.scene.layout.Region.maxHeight(Region.java:1204)
              at javafx.scene.layout.Region.layoutInArea(Region.java:1806)
              at javafx.scene.layout.Region.layoutInArea(Region.java:1768)
              at javafx.scene.layout.HBox.layoutChildren(HBox.java:529)
              at javafx.scene.Parent.layout(Parent.java:1012)
              at javafx.scene.Scene.layoutDirtyRoots(Scene.java:517)
              at javafx.scene.Scene.doLayoutPass(Scene.java:488)
              at javafx.scene.Scene.access$3900(Scene.java:172)
              at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2222)
              at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:346)
              at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:502)
              at com.sun.javafx.tk.quantum.QuantumToolkit$11.run(QuantumToolkit.java:355)
              at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
              at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
              at com.sun.glass.ui.win.WinApplication$3$1.run(Unknown Source)
              at java.lang.Thread.run(Thread.java:662)

        Attachments

          Activity

            People

            • Assignee:
              fheidric Felipe Heidrich (Inactive)
              Reporter:
              ogb Oleg Barbashov (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: