Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6788484
Votes 0
Synopsis NPE in DefaultTableCellHeaderRenderer.getColumnSortOrder() with null table
Category java:classes_swing
Reported Against
Release Fixed 6u14(b03)
State 11-Closed, Unverified, bug
Priority: 3-Medium
Related Bugs 6777378
Submit Date 23-DEC-2008
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
Passing a null table to DefaultTableCellHeaderRenderer.getColumnSortOrder() causes a NullPointerException.  This problem was probably introduced by a fix to 6668281 that came out in 1.6.0_10.



ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
	at sun.swing.table.DefaultTableCellHeaderRenderer.getColumnSortOrder(Unknown Source)
	at com.sun.java.swing.plaf.windows.WindowsTableHeaderUI$XPDefaultRenderer.getTableCellRendererComponent(Unknown Source)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;

public class Bug6668281 {

    private static void createGui() {

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            e.printStackTrace();
        }
        JTable table = new JTable();
        JTableHeader header = table.getTableHeader();
        TableCellRenderer headerRenderer = header.getDefaultRenderer();
        headerRenderer.getTableCellRendererComponent(null, "test", false, true, -1, 0);
        System.out.println("end...");
    }

    public static void main(String[] args) throws Exception {
        Bug6668281.createGui();
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Two workarounds listed for 6668281 worked for me too:

Workaround #1
1. Right-click on the application shortcut.
2. Select "Property"
3. Click on "Compatibility"
4. Click on the box "Disable Visual Theme"

Workaround #2
1.  Right click on an empty part of the desktop.
2.  Select "Personalize"
3.  Click "Window Color and Appearance"
4.  If currently using Aero, then click "Open classic appearance properties" link at bottom, OTHERWISE skip to step 5.
5.  In the Color scheme list, click "Windows Classic" and then click OK.
6.  Restart your broken Java app -- the exception should now not be thrown.

Release Regression From : 6u10
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.
Posted Date : 2008-12-23 11:42:02.0
Work Around
N/A
Evaluation
NPE happens in DefaultTableCellHeaderRenderer.getColumnSortOrder(JTable, int) method,
it doesn't check the passed JTable instance for null and calls table.getRowSorter()

Need to add a null check
Posted Date : 2009-02-27 14:19:34.0

Note that the provided test case throws NPE only when is run on Vista
Posted Date : 2009-02-27 14:20:25.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang