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

NullPointerException from JComboBox and JList when Accessibility enabled

    Details

      Backports

        Description

        The following JList test code generates a NullPointerException (below) when the accessibility subsystem is active (imports not included):

        public class TestJList extends JFrame {
            private final static String [] ANIMALS = {
                    "Bird", "Cat", "Dog", "Rabbit", "Pig"
            };

            TestJList () {
                DefaultListModel<String> model = new DefaultListModel<>();
                for (String s : ANIMALS) {
                    model.addElement(s);
                }

                JList<String> list = new JList<>(model);
                list.addKeyListener(new KeyAdapter() {
                    public void keyPressed(KeyEvent e) {
                        if ( e.getKeyChar() == KeyEvent.VK_ENTER
                            || e.getKeyCode() == KeyEvent.VK_ENTER) {

                            String s = list.getSelectedValue();
                            model.removeAllElements();
                            model.addElement(s);
                        }
                    }
                });

                add(list);
                pack();
            }

            public static void main(String args[]) {
                TestJList tj = new TestJList();
                tj.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {
                        System.exit(0);
                    }
                });

                tj.setLocationRelativeTo(null);
                tj.setVisible(true);
            }

        stacktrace:
        ....
        java.lang.RuntimeException: java.lang.NullPointerException
            at com.sun.java.accessibility.AccessBridge$InvocationUtils.invokeAndWait(AccessBridge.java:7206)
            at com.sun.java.accessibility.AccessBridge$InvocationUtils.invokeAndWait(AccessBridge.java:7181)
            at com.sun.java.accessibility.AccessBridge.getAccessibleActionFromContext(AccessBridge.java:1782)
            at com.sun.java.accessibility.AccessBridge.runDLL(Native Method)
            at com.sun.java.accessibility.AccessBridge.access$300(AccessBridge.java:57)
            at com.sun.java.accessibility.AccessBridge$dllRunner.run(AccessBridge.java:141)
            at java.lang.Thread.run(Thread.java:745)
        Caused by: java.lang.NullPointerException
            at javax.swing.JList$AccessibleJList$AccessibleJListChild.getAccessibleAction(JList.java:3374)
            at com.sun.java.accessibility.AccessBridge$70.call(AccessBridge.java:1785)
            at com.sun.java.accessibility.AccessBridge$70.call(AccessBridge.java:1782)
            at com.sun.java.accessibility.AccessBridge$InvocationUtils$CallableWrapper.run(AccessBridge.java:7262)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
            at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
            at java.awt.EventQueue.access$500(EventQueue.java:97)
            at java.awt.EventQueue$3.run(EventQueue.java:709)
            at java.awt.EventQueue$3.run(EventQueue.java:703)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)


        To reproduce the exception use the keyboard to navigate to any item in the JList after "Bird" and press the Enter key.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  aivanov Alexey Ivanov
                  Reporter:
                  shadowbug Shadow Bug
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Due:
                    Created:
                    Updated:
                    Resolved: