Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8043513

Clipboard#getContents(Object) throws IOException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 9
    • 7u15, 8, 9
    • client-libs
    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.7.0_15"
      Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
      Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Running the 32Bit JDK on a 64Bit System

      * I am using a Linux Mint Operating System on my machine
      * I am connected via RDP to the Windows 7 machine
      ** The RDP connection is configured to share the clipboard

      A DESCRIPTION OF THE PROBLEM :
      I'm not able to give a complete guide on how to reproduce the problem because it seems to be a special situation. I think someone looking at the jvm code will be able to find and solve the problem anyway.

      I am using the following code on the Windows machine after establishing the RDP connection:

      1 final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
      2 clipboard.getContents(null);

      The second line causes the following exception:

      java.io.IOException: system clipboard data unavailable
      at sun.awt.windows.WClipboard.getClipboardData(Native Method)
      at sun.awt.datatransfer.ClipboardTransferable.fetchOneFlavor(ClipboardTransferable.java:118)
      at sun.awt.datatransfer.ClipboardTransferable.<init>(ClipboardTransferable.java:97)
      at sun.awt.datatransfer.SunClipboard.getContents(SunClipboard.java:147)
              ...

      Problem: The javadoc for Clipboard#getContents states that in the case the clipboard is not available an IllegalStateException is thrown. The IOException is not included in the methods throws-clause.

      If I disable clipboard sharing in RDP it works without problems.
      If I copy something into the clipboard after establishing the connection but before invoking the code it works without problems.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
      clipboard.getContents(null);
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Catch Exception instead of IOException when invoking Clipboard#getContents(Object)

            pchelko Petr Pchelko (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: