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

DefaultCellEditor.getTableCellEditorComponent -> potential stack overflow

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b12
    • Introduced In Version:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_10-rc"
      Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)
      Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP

      A DESCRIPTION OF THE PROBLEM :
      The DefaultCellEditor.getTableCellEditorComponent source now calls getTableCellRendererComponent if the editorComponent is a JCheckBox, it did not in previous versions.

      I'm not sure if calling getTableCellEditorComponent from the getTableCellRendererComponent method is bad practice but I've already got code in custom TableCellRenderers' getTableCellRendererComponent methods that calls "table.getCellEditor(row, column).getTableCellEditorComponent" to get the checkbox and set the border. This code now results in a stack overflow.

      I can change my code but just upgrading to 1.6.0_10 will result in stack overflows.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a JTable and add some cells that result in JCheckBoxes (create a DefaultTableModel with getColumnClass overridden to return boolean)

      Create a custom TableCellRenderer and add the following method...
      public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
                  int row, int column)
      {
      table.getCellEditor(row, column).getTableCellEditorComponent(table, value, isSelected, row, column);
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Better display of JCheckBox within a JTable
      ACTUAL -
      Stack overflow

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Do not call the getTableCellEditorComponent method from the getTableCellRendererComponent method of a custom TableCellRenderer

      Release Regression From : 6u7
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              peterz Peter Zhelezniakov
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: