JDK-6511815 : NPE from XSelection.checkChange
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0,5.0u10,6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2007-01-10
  • Updated: 2011-05-19
  • Resolved: 2011-05-18
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 6 JDK 7
6u2Fixed 7 b09Fixed
Related Reports
Duplicate :  
Description
Sometimes when using (6.0) development builds of the NetBeans IDE and invoking some drag-and-drop operation (in the Gnome environment on FC 6 Linux) I get an exception:

java.lang.NullPointerException
        at sun.awt.X11.XSelection.checkChange(XSelection.java:701)
        at sun.awt.X11.XSelection.access$200(XSelection.java:28)
        at sun.awt.X11.XSelection$SelectionEventHandler.dispatchEvent(XSelection.java:710)
        at sun.awt.X11.XToolkit.dispatchEvent(XToolkit.java:408)
        at sun.awt.X11.XToolkit.run(XToolkit.java:493)
        at sun.awt.X11.XToolkit.run(XToolkit.java:438)
        at java.lang.Thread.run(Thread.java:595)

The above is from 1.5.0_10 and arose from a D&D operation on a Java class in the Packages view.

Comments
EVALUATION Here is a problematic code: XSelection selection = getSelection(selectionAtom); if (selection != null) { selection.isSelectionNotifyProcessed = true; selection.clipboard.checkChange(formats); } it looks like sometime clipboard is null and we do not handle this (in this particular place), all other places which work with clipboard check it for null. So, it looks like we should also add the check here.
12-01-2007

SUGGESTED FIX --- XSelection.java 2007-01-12 19:22:14.000000000 +0300 *************** *** 30,36 **** public class XSelection { /* Maps atoms to XSelection instances. */ ! private static final Hashtable table = new Hashtable(); /* Prevents from parallel selection data request processing. */ private static final Object lock = new Object(); /* The property in which the owner should place the requested data. */ --- 30,36 ---- public class XSelection { /* Maps atoms to XSelection instances. */ ! private static final Hashtable<XAtom, XSelection> table = new Hashtable<XAtom, XSelection>(); /* Prevents from parallel selection data request processing. */ private static final Object lock = new Object(); /* The property in which the owner should place the requested data. */ *************** *** 113,119 **** * <code>null</code> if none exists. */ static XSelection getSelection(XAtom atom) { ! return (XSelection)table.get(atom); } /** --- 113,119 ---- * <code>null</code> if none exists. */ static XSelection getSelection(XAtom atom) { ! return table.get(atom); } /** *************** *** 746,752 **** XSelection selection = getSelection(selectionAtom); if (selection != null) { selection.isSelectionNotifyProcessed = true; ! selection.clipboard.checkChange(formats); } } --- 746,754 ---- XSelection selection = getSelection(selectionAtom); if (selection != null) { selection.isSelectionNotifyProcessed = true; ! if (selection.clipboard != null) { ! selection.clipboard.checkChange(formats); ! } } }
12-01-2007