JDK-8179547 : [linux] Clipboard.setContents works in Windows and Mac OS, but not in Linux
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8,9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • CPU: x86_64
  • Submitted: 2017-05-01
  • Updated: 2019-03-23
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.
Other
tbdUnresolved
Description
FULL PRODUCT VERSION :
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux limac 4.10.11-200.fc25.x86_64 #1 SMP Tue Apr 18 17:25:01 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
The Clipboard.setContents should put some contents in the system clipboard, and this function works great in Windows and Mac OS.  But on linux, this does not work.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. compile the attached source code in Windows, Mac OS, and in Linux.
   (javac -d cls Test.java)
2. run this test program.
  (java -cp cls test.Test)
3. paste in any application that accept text input.  In both Windows and Mac OS, I get "copy and paste", but in Linux, I get nothing.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect the paste action to produce "copy and paste" text.
ACTUAL -
I got nothing.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error message.  The clipboard is just empty.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package test;

import java.awt.*;
import java.awt.datatransfer.*;

public class Test {
  public static void main(String[] args) {
    StringSelection ss = new StringSelection("copy and paste");
    Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
    cb.setContents(ss, null);
  }
}
---------- END SOURCE ----------


Comments
Reproducible with JDK 9-ea-167 and 8GA on Ubuntu 14.04.
04-05-2017

Reproducible only in Linux. Ubuntu 14.04.1 LTS (3.13.0-32-generic #57-Ubuntu SMP) ------- 8 GA : Fail 8u121 : Fail 8u131 : Fail 8u152 : Fail 9ea167 : Fail
03-05-2017