From 3357f6846cd23a17fde4b9d6c4179811dfd5a33f Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 10 Aug 2017 10:46:19 +0530 Subject: [PATCH] 8185890: Intermittent NPE in JLightweightFrame when updating cursor aceoss multiple graphics devices Reviewed-by: azvegint --- .../share/classes/sun/swing/JLightweightFrame.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java b/jdk/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java index 14b3eaa61a0..589c22280c4 100644 --- a/jdk/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java +++ b/jdk/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java @@ -509,7 +509,16 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan * and could not be overridden. */ private void updateClientCursor() { - Point p = MouseInfo.getPointerInfo().getLocation(); + PointerInfo pointerInfo = MouseInfo.getPointerInfo(); + if (pointerInfo == null) { + /* + * This can happen when multiple graphics device cannot decide + * which graphics device contains the current mouse position + * or on systems without a mouse + */ + return; + } + Point p = pointerInfo.getLocation(); SwingUtilities.convertPointFromScreen(p, this); Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y); if (target != null) {