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

StringIndexOutOfBoundsException in MacAccessible.java:1823

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      macOS Catalina10.15.1
      Java 1.8u201

      A DESCRIPTION OF THE PROBLEM :
      If you enable VoiceOver in Accessibility settings, run the test program and select the File->Crash menu, the application will crash.

      The test program has a TextField with some text. The menu item simply replaces that text with a shorter string.

      The exception thrown is:
      Exception in thread "JavaFX Application Thread" java.lang.StringIndexOutOfBoundsException: String index out of range: 9
      at java.lang.String.substring(String.java:1963)
      at com.sun.glass.ui.mac.MacAccessible.accessibilityAttributeValueForParameter(MacAccessible.java:1823)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Enable VoiceOver in Accessibility Settings
      Run the supplied test program
      Select the File->Crash menu
      Crash

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Application shouldn't crash
      ACTUAL -
      Exception in thread "JavaFX Application Thread" java.lang.StringIndexOutOfBoundsException: String index out of range: 9
      at java.lang.String.substring(String.java:1963)
      at com.sun.glass.ui.mac.MacAccessible.accessibilityAttributeValueForParameter(MacAccessible.java:1823)

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Menu;
      import javafx.scene.control.MenuBar;
      import javafx.scene.control.MenuItem;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class HelloWorld extends Application
      {

          @Override
          public void start(
              Stage primaryStage)
          {
              TextField textField1 = new TextField();
              textField1.setText("some text");
              
              MenuBar menuBar = new MenuBar();
              menuBar.setUseSystemMenuBar(true);
              Menu menuFile = new Menu("File");
              menuBar.getMenus().addAll(menuFile);
              
              MenuItem add = new MenuItem("Crash");
              add.setOnAction(e -> textField1.setText("text"));
              menuFile.getItems().add(add);
              
              VBox root = new VBox();
              root.getChildren().add(textField1);

              Scene scene = new Scene(root, 300, 250);

              ((VBox) scene.getRoot()).getChildren().addAll(menuBar);
              primaryStage.setTitle("Hello World!");
              primaryStage.setScene(scene);
              primaryStage.show();
              

          }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Don't use VoiceOver

      FREQUENCY : always


            arapte Ambarish Rapte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: