7184951: [macosx] Exception at java.awt.datatransfer on headless mode (only in GUI session)
authorpchelko
Tue, 23 Jul 2013 13:09:44 +0400
changeset 19020 1f20de4aef29
parent 19019 622c39d5e9ee
child 19021 8a5340b88ee5
7184951: [macosx] Exception at java.awt.datatransfer on headless mode (only in GUI session) Reviewed-by: art, anthony
jdk/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Mon Jul 22 20:33:35 2013 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Tue Jul 23 13:09:44 2013 +0400
@@ -182,7 +182,11 @@
         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);
         }