java.lang.IndexOutOfBoundsException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • FULL PRODUCT VERSION : 1.8.0_102 ADDITIONAL OS VERSION INFORMATION : Windows10 (64bit) A DESCRIPTION OF THE PROBLEM : In some cases, MultipleSelectionModelBase produces improper ListChangeListener.Change which have illegal from/to index. So, if getAddedSubList is invoked on such Change, it causes IndexOutOfBoundsException. It seems to me that implementation of MultiSelectionModelBase.selectedIndicesSeq field is the cause of this problem. This field is generated by createListFromBitSet, and provides the ObservableList view of BitMap field 'selectedIndices'. I think the cause of this problem is the internal state (lastGetIndex/lastGetValue) of this instance is not properly maintained when content of 'selectedIndices' is changed. For example, in my code for reproduction, the value of selectedIndices and lastGetIndex/lastGetValue changed as follows: A) Ater selection "a" and "b" selectedIndices = { 0, 1 } lastGetIndex/lastGetValue = 1/1 (cosistent) B) after quietClearSelection() in clearAndSelect() selectedIndices = { } lastGetIndex/lastGetValue = 1/1 (inconsistent) C) After select() in clearAndSelect() selectedIndices = { 2 } lastGetIndex/lastGetValue = 1/1 (inconsistent) At last, line 373 in MultiSelectionModelBase.java, indexOf(2) returns incorrect index -1 (expected result is 0). 373: int changeIndex = selectedIndicesSeq.indexOf(row); 374: change = new NonIterableChange.GenericAddRemoveChange<>( 375: changeIndex, changeIndex+1, previousSelectedIndices, selectedIndicesSeq); STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run my reproduce program and push 'reproduce' button. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - selection changed added 0 1 [a] selection changed added 1 2 [b] selection changed removed 0 1 [a, b] added 0 1 [c] ACTUAL - selection changed added 0 1 [a] selection changed added 1 2 [b] selection changed removed -1 0 [a, b] added -1 0 =>java.lang.IndexOutOfBoundsException in thread "JavaFX Application Thread" ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException at com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList.subList(ReadOnlyUnbackedObservableList.java:136) at javafx.collections.ListChangeListener$Change.getAddedSubList(ListChangeListener.java:242) at test.App.lambda$0(App.java:34) at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164) at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73) at com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList.callObservers(ReadOnlyUnbackedObservableList.java:75) at javafx.scene.control.MultipleSelectionModelBase$1.onChanged(MultipleSelectionModelBase.java:97) at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329) at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73) at com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList.callObservers(ReadOnlyUnbackedObservableList.java:75) at javafx.scene.control.MultipleSelectionModelBase.clearAndSelect(MultipleSelectionModelBase.java:378) at javafx.scene.control.ListView$ListViewBitSetSelectionModel.clearAndSelect(ListView.java:1403) at test.App.lambda$1(App.java:44) ... REPRODUCIBILITY : This bug can be reproduced often. ---------- BEGIN SOURCE ---------- package test; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ListChangeListener.Change; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ListView; import javafx.scene.control.MultipleSelectionModel; import javafx.scene.control.SelectionMode; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class App extends Application { static void log(String fmt, Object...args) { System.out.format(fmt, args); } @Override public void start(Stage primaryStage) { ListView<String> listView = new ListView<>( FXCollections.observableArrayList("a", "b", "c")); MultipleSelectionModel<String> sm = listView.getSelectionModel(); sm.setSelectionMode(SelectionMode.MULTIPLE); sm.getSelectedItems().addListener((Change<? extends String> c) -> { log("selection changed\n"); while (c.next()) { if (c.wasRemoved()) { log(" removed %d %d\n", c.getFrom(), c.getTo()); log(" %s\n", c.getRemoved()); } if (c.wasAdded()) { log(" added %d %d\n", c.getFrom(), c.getTo()); log(" %s\n", c.getAddedSubList()); } } }); Button button = new Button("reproduce"); button.setOnAction((ev) -> { sm.clearSelection(); sm.select(0); sm.select(1); // following invocation causes IndexOutOfBoundsException sm.clearAndSelect(2); }); VBox root = new VBox(button, listView); Scene scene = new Scene(root); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } } ---------- END SOURCE ----------
    via by Webbug Group,
  • JavaFx8 Tableview updating ObservableList
    via by Unknown author,
  • ComboBox selectionModel error
    via Stack Overflow by Rolandas Janulis
    ,
  • removing items from combo boxe in java 8
    via Stack Overflow by Ionterac
    ,
  • 1. open hello.HTMLEditor 2. enter some text (at least 3 lines) 3. Select all --> "Paragraph" --> "Heading " Used javafx build "329" (Sanity testing, non-jigsaw mode) ----- HelloHTMLEditor ----- java -ea -DproxyHost=www-proxy.us.oracle.com -DproxyPort=80 -cp D:\ws\jdk9\ea109\jdk-9/lib/jfxrt.jar;dist/Hello.jar hello.HelloHTMLEditor Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException at com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList.subList(ReadOnlyUnbackedObservableList.java:136) at javafx.collections.ListChangeListener$Change.getAddedSubList(ListChangeListener.java:242) at com.sun.javafx.scene.control.behavior.ListViewBehavior.lambda$new$55(ListViewBehavior.java:281) at javafx.collections.WeakListChangeListener.onChanged(WeakListChangeListener.java:88) at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329) at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73) at com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList.callObservers(ReadOnlyUnbackedObservableList.java:75) at javafx.scene.control.MultipleSelectionModelBase.clearAndSelect(MultipleSelectionModelBase.java:422) at javafx.scene.control.ListView$ListViewBitSetSelectionModel.clearAndSelect(ListView.java:1403) at com.sun.javafx.scene.control.behavior.CellBehaviorBase.simpleSelect(CellBehaviorBase.java:281) at com.sun.javafx.scene.control.behavior.CellBehaviorBase.doSelect(CellBehaviorBase.java:245) at com.sun.javafx.scene.control.behavior.CellBehaviorBase.mousePressed(CellBehaviorBase.java:175) at com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274) at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at javafx.event.Event.fireEvent(Event.java:198) at javafx.scene.Scene$MouseHandler.process(Scene.java:3894) at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3622) at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1883) at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2631) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:353) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:389) at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:388) at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:388) at com.sun.glass.ui.View.handleMouseEvent(View.java:555) at com.sun.glass.ui.View.notifyMouse(View.java:937) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:189) at java.lang.Thread.run(Thread.java:804)
    via by Guru Hb,
    • java.lang.IndexOutOfBoundsException at com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList.subList(ReadOnlyUnbackedObservableList.java:136) at javafx.collections.ListChangeListener$Change.getAddedSubList(ListChangeListener.java:242) at test.App.lambda$0(App.java:34) at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164) at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73) at com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList.callObservers(ReadOnlyUnbackedObservableList.java:75) at javafx.scene.control.MultipleSelectionModelBase$1.onChanged(MultipleSelectionModelBase.java:97) at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329) at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73) at com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList.callObservers(ReadOnlyUnbackedObservableList.java:75) at javafx.scene.control.MultipleSelectionModelBase.clearAndSelect(MultipleSelectionModelBase.java:378) at javafx.scene.control.ListView$ListViewBitSetSelectionModel.clearAndSelect(ListView.java:1403) at test.App.lambda$1(App.java:44)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor2 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,