From 5fc2c0620ac3b585ff0751ed1f8ef7349935dc0e Mon Sep 17 00:00:00 2001 From: pchelko Date: Tue, 23 Jul 2013 13:09:44 +0400 Subject: [PATCH] 7184951: [macosx] Exception at java.awt.datatransfer on headless mode (only in GUI session) Reviewed-by: art, anthony --- src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java index 35c6ef6d5..b4f0f9782 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java +++ b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java @@ -182,7 +182,11 @@ public class CDataTransferer extends DataTransferer { Long format = predefinedClipboardNameMap.get(str); if (format == null) { - format = new Long(registerFormatWithPasteboard(str)); + if (java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) { + // Do not try to access native system for the unknown format + return -1L; + } + format = registerFormatWithPasteboard(str); predefinedClipboardNameMap.put(str, format); predefinedClipboardFormatMap.put(format, str); } -- GitLab