-
Bug
-
Resolution: Fixed
-
P4
-
jfx11, 8u241, 9, jfx14, jfx15
To reproduce, compile and run the example below and see the stacktrace.
This turned up during binch testing forJDK-8244112 for all controls (failed in sanity test of setup state) Will exclude MenuBar with a pointer to this issue.
The example:
/**
* Empty MenuBar throws IIOOB on requestFocus.
*/
public class MenuBarEmptyRequestFocus extends Application {
private MenuBar bar;
private Parent createContent() {
bar = new MenuBar();
VBox content = new VBox(bar);
return content;
}
@Override
public void start(Stage stage) throws Exception {
stage.setScene(new Scene(createContent()));
stage.show();
bar.requestFocus();
}
public static void main(String[] args) {
launch(args);
}
}
Stacktrace:
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:458)
at javafx.base/com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
at javafx.controls/javafx.scene.control.skin.MenuBarSkin.setFocusedMenuIndex(MenuBarSkin.java:478)
at javafx.controls/javafx.scene.control.skin.MenuBarSkin.menuModeStart(MenuBarSkin.java:1081)
at javafx.controls/javafx.scene.control.skin.MenuBarSkin.lambda$5(MenuBarSkin.java:307)
at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72)
at javafx.graphics/javafx.scene.Node$FocusedProperty.notifyListeners(Node.java:8154)
at javafx.graphics/javafx.scene.Scene$4.invalidated(Scene.java:2197)
at javafx.base/javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
at javafx.base/javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147)
at javafx.graphics/javafx.scene.Scene$KeyHandler.setFocusOwner(Scene.java:4058)
at javafx.graphics/javafx.scene.Scene$KeyHandler.requestFocus(Scene.java:4105)
at javafx.graphics/javafx.scene.Scene.requestFocus(Scene.java:2161)
at javafx.graphics/javafx.scene.Node.requestFocus(Node.java:8315)
at use_openjfx/control.skin.MenuBarEmptyRequestFocus.start(MenuBarEmptyRequestFocus.java:54)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$11(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$10(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$4(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:835)
This turned up during binch testing for
The example:
/**
* Empty MenuBar throws IIOOB on requestFocus.
*/
public class MenuBarEmptyRequestFocus extends Application {
private MenuBar bar;
private Parent createContent() {
bar = new MenuBar();
VBox content = new VBox(bar);
return content;
}
@Override
public void start(Stage stage) throws Exception {
stage.setScene(new Scene(createContent()));
stage.show();
bar.requestFocus();
}
public static void main(String[] args) {
launch(args);
}
}
Stacktrace:
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:458)
at javafx.base/com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
at javafx.controls/javafx.scene.control.skin.MenuBarSkin.setFocusedMenuIndex(MenuBarSkin.java:478)
at javafx.controls/javafx.scene.control.skin.MenuBarSkin.menuModeStart(MenuBarSkin.java:1081)
at javafx.controls/javafx.scene.control.skin.MenuBarSkin.lambda$5(MenuBarSkin.java:307)
at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72)
at javafx.graphics/javafx.scene.Node$FocusedProperty.notifyListeners(Node.java:8154)
at javafx.graphics/javafx.scene.Scene$4.invalidated(Scene.java:2197)
at javafx.base/javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
at javafx.base/javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147)
at javafx.graphics/javafx.scene.Scene$KeyHandler.setFocusOwner(Scene.java:4058)
at javafx.graphics/javafx.scene.Scene$KeyHandler.requestFocus(Scene.java:4105)
at javafx.graphics/javafx.scene.Scene.requestFocus(Scene.java:2161)
at javafx.graphics/javafx.scene.Node.requestFocus(Node.java:8315)
at use_openjfx/control.skin.MenuBarEmptyRequestFocus.start(MenuBarEmptyRequestFocus.java:54)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$11(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$10(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$4(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:835)