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

[VirtualFlow] When item is added then changed right after, AIOOB occurs during layout

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 8u20
    • 8u20
    • javafx
    • Java 8u-dev repo tip, Linux

      This may be a duplicate or just a very similar issue to RT-37015. In our application an item is added to a list in our ui and then a few lines later it might be updated to a new value. This scenario seems to cause another AIOOB.

      1. To reproduce run the following test class and click on the button to add a cell.

      The code adds a new item and then right away changes that item which causes the error to occur.

      ***************************************** Test Class *************************************************
      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ListView;
      import javafx.scene.control.SelectionMode;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class ListViewTest extends Application {

         @Override public void start(final Stage primaryStage) throws Exception {

            final ListView<Integer> list = new ListView<>();
            list.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
             
            primaryStage.centerOnScreen();
            primaryStage.setHeight(350);
            primaryStage.setWidth(500);
             
            Button button = new Button("Add Cell");
            button.setOnAction(new EventHandler<ActionEvent>() {
               @Override public void handle(ActionEvent event) {
                  Integer newItem = list.getItems().size() + 1;
                  list.getItems().add(newItem);
                  int idx = list.getItems().size() - 1;
                  list.getItems().set(idx, newItem + 1);
               }
            });
            
            primaryStage.setScene(new Scene(new VBox(20, list, button)));

            primaryStage.show();
             
         }

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

      }

            jgiles Jonathan Giles
            csmithjfx Charles Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: