JDK-8025126 : [macosx] Invalid calls to setValueAt() within JTable in Java 7 on Mac OS X
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7,7u40
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2013-09-20
  • Updated: 2014-03-11
  • Resolved: 2013-11-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b119Fixed
Related Reports
Duplicate :  
Relates :  
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).
Comments
java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java PASSED under JDK 8 b132 on MacOS, Linux, Solaris, Windows. Closed issue as Fixed/Verified.
11-03-2014

Release team: Approved for fixing
25-11-2013

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
19-11-2013

Release team: It's unclear if this is a deferral request or a critical request. Please clarify and add justification for fixing.
19-11-2013

SQE: OK.
15-11-2013

-- 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
15-11-2013

HG Updates added a comment - 2013-11-15 02:08 URL: http://hg.openjdk.java.net/jdk8/awt/jdk/rev/0d5cc1f305c6 User: alexsch Date: 2013-11-15 10:06:48 +0000
15-11-2013

The extended key code is not correctly set in the LWWindowPeer if the key char is undefined.
12-11-2013

jdk8: SQE OK to defer
02-10-2013

defer justification: Not a regression for JDK-8, reproducible since 7GA (last worked in 6u45). Does not have a significant effect on client applications, there's an easy workaround.
02-10-2013