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

javax.swing.DefaultTableCellRender.getTableCellRendererComponent() doesn't allow passing null Tables

    Details

    • Subcomponent:
    • Resolved In Build:
      b118
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        The spec for TableCellRenderer.getTableCellRendererComponent() says:

           * @param table the <code>JTable</code> that is asking the
           * renderer to draw; can be <code>null</code>

        But DefaultTableCellRenderer implementation will throw NPE if 'null' table is passed. Please see the following code sample:

        ---
        import javax.swing.*;

        public class NPE {

            public static void main(String[] args) {
                new JTable().getDefaultRenderer(Object.class).
                        getTableCellRendererComponent(null, "a value", true, true, 0, 0);
            }
        }
        ---
        Exception in thread "main" java.lang.NullPointerException
        at javax.swing.table.DefaultTableCellRenderer.getTableCellRendererComponent(DefaultTableCellRenderer.java:177)
        ...
        ---

        The following JCK test fails:

        api/javax_swing/table/TableCellRenderer/index.html#GetComponent[TableCellRenderer0001]

        JCK-runtime-7 b03
        JDK: 6, 7
        Platforms: Windows, Solaris
        There is no this test in jdk 1.5.0 but the same problem exists.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  rupashka Pavel Porvatov (Inactive)
                  Reporter:
                  dbessono Dmitry Bessonov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: