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

[macosx] Invalid calls to setValueAt() within JTable in Java 7 on Mac OS X

    Details

    • Subcomponent:
    • Resolved In Build:
      b119
    • OS:
      os_x
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.7.0_40"
        Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
        Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Mac OS X 10.8.5 (12F37)
        But the issue is reproduced even in Mac OS X 10.7

        A DESCRIPTION OF THE PROBLEM :
        While using the arrow keys to navigate within an editable JTable invalid calls of the setValueAt() method from the TableModel appear. The problem appears only on Mac OS X and not on Windows.

        REGRESSION. Last worked in version 6u45

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the test, select a line within the table and use the arrow key to move to other lines. You will see printed to system.out that setValueAt() method is called although nothing should be printed.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The application should do nothing and print nothing.
        ACTUAL -
        The application performs invalid calls to setValueAt().

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.Color;
        import java.awt.event.WindowAdapter;
        import java.awt.event.WindowEvent;

        import javax.swing.JFrame;
        import javax.swing.JTable;
        import javax.swing.table.DefaultTableModel;

        public class Test {

        private static void runTest() {
        JFrame frame = new JFrame();
        JTable table = new JTable(new TestTableModel(10,10));
        table.setShowGrid(true);
        table.setGridColor(Color.GRAY);
        frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
        System.exit(0);
        }
        });
        frame.add(table);
        frame.pack();
        frame.setVisible(true);
        }

        public static void main(String[] args) {
        // Schedule a job for the event-dispatching thread:
        // creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
        runTest();
        }
        });
        }
        }

        class TestTableModel extends DefaultTableModel {
        /**
         *
         */
        private static final long serialVersionUID = 1L;

        public TestTableModel(int rowCount, int columnCount) {
        super(rowCount, columnCount);
        }

        @Override
        public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        System.out.println("set value");
        }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        This can somehow be avoided by using:
        putClientProperty("JTable.autoStartsEdit", Boolean.FALSE);

        But has the drawback that editing will only start after a mouse event (double-click for example).

          Issue Links

            Activity

            Hide
            maxelsso Mathias Axelsson (Inactive) added a comment -
            Release team: It's unclear if this is a deferral request or a critical request. Please clarify and add justification for fixing.
            Show
            maxelsso Mathias Axelsson (Inactive) added a comment - Release team: It's unclear if this is a deferral request or a critical request. Please clarify and add justification for fixing.
            Hide
            vdyakov Victor Dyakov added a comment - - edited
            This is 8-critical-request after revisited triage, the problem much more serious and affecting more developers than estimated before. So the team decided to to resubmit this issue as critical.
            Low risks safe fix approved by SQE
            Affects real applications: The application performs invalid calls to setValueAt(), affecting Java 8 on Mac OS X platform.

               -- webrev http://cr.openjdk.java.net/~alexsch/8025126/webrev.00
               -- review http://mail.openjdk.java.net/pipermail/awt-dev/2013-November/006309.html
               -- issue impact: setValueAt() method will be called each time when a user press an arrow key. So the method will be incorrectly invoked even a cell was not edited.
               -- fix rational (briefly): impacts JTable cells editing
               -- risks level (Low|Med|high and affected func/components) Low, KeyEvent, JTable
               -- suggested testing (reg test, etc): runt regression test test/java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java
            Show
            vdyakov Victor Dyakov added a comment - - edited This is 8-critical-request after revisited triage, the problem much more serious and affecting more developers than estimated before. So the team decided to to resubmit this issue as critical. Low risks safe fix approved by SQE Affects real applications: The application performs invalid calls to setValueAt(), affecting Java 8 on Mac OS X platform.    -- webrev http://cr.openjdk.java.net/~alexsch/8025126/webrev.00    -- review http://mail.openjdk.java.net/pipermail/awt-dev/2013-November/006309.html    -- issue impact: setValueAt() method will be called each time when a user press an arrow key. So the method will be incorrectly invoked even a cell was not edited.    -- fix rational (briefly): impacts JTable cells editing    -- risks level (Low|Med|high and affected func/components) Low, KeyEvent, JTable    -- suggested testing (reg test, etc): runt regression test test/java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java
            Hide
            maxelsso Mathias Axelsson (Inactive) added a comment -
            Release team: Approved for fixing
            Show
            maxelsso Mathias Axelsson (Inactive) added a comment - Release team: Approved for fixing
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/0d5cc1f305c6
            User: lana
            Date: 2013-12-03 19:10:36 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/0d5cc1f305c6 User: lana Date: 2013-12-03 19:10:36 +0000
            Hide
            rsloan Rocky Sloan added a comment -
            java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java

            PASSED under JDK 8 b132 on MacOS, Linux, Solaris, Windows.
            Closed issue as Fixed/Verified.
            Show
            rsloan Rocky Sloan added a comment - java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java PASSED under JDK 8 b132 on MacOS, Linux, Solaris, Windows. Closed issue as Fixed/Verified.

              People

              • Assignee:
                alexsch Alexander Scherbatiy
                Reporter:
                ndcosta Nelson Dcosta
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: