JDK-8286481 : Exception printed to stdout on Windows when storing transparent image in clipboard
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6,7,8,11,17
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • Submitted: 2022-05-10
  • Updated: 2023-10-02
  • Resolved: 2022-06-06
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.
JDK 11 JDK 17 JDK 19 JDK 8
11.0.21-oracleFixed 17.0.9-oracleFixed 19 b26Fixed 8u381Fixed
Description
When storing a transparent image (bitmap with an alpha channel) in the system clipboard on Windows, at exception is printed to standard out, like this:

java.io.IOException: Registered service providers failed to encode BufferedImage@5a01ccaa: type = 2 DirectColorModel: rm
ask=ff0000 gmask=ff00 bmask=ff amask=ff000000 IntegerInterleavedRaster: width = 1 height = 1 #Bands = 4 xOff = 0 yOff =
0 dataOffset[0] 0 to image/jpeg
        at java.desktop/sun.awt.datatransfer.DataTransferer.imageToStandardBytesImpl(DataTransferer.java:1799)
        at java.desktop/sun.awt.datatransfer.DataTransferer.imageToStandardBytes(DataTransferer.java:1713)
        at java.desktop/sun.awt.windows.WDataTransferer.imageToPlatformBytes(WDataTransferer.java:353)
        at java.desktop/sun.awt.datatransfer.DataTransferer.translateTransferable(DataTransferer.java:855)
        at java.desktop/sun.awt.windows.WDataTransferer.translateTransferable(WDataTransferer.java:220)
        at java.desktop/sun.awt.windows.WClipboard.setContentsNative(WClipboard.java:83)
        at java.desktop/sun.awt.datatransfer.SunClipboard.setContents(SunClipboard.java:105)

The exception is not passed on to user code; it is just consumed and printed to the console in sun.awt.windows.WClipboard.setContentsNative().

Despite the printed exception, the actual copy works just fine anyway. So this is just annoying noise to the user.


Comments
Fix Request (11u) This backport is for parity with 11.0.21-oracle. Applies cleanly. Nightly tests run without related issues..
25-07-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk11u-dev/pull/2054 Date: 2023-07-21 10:28:43 +0000
21-07-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/1471 Date: 2023-06-19 15:52:25 +0000
19-06-2023

Fix Request (17u): Should get backported for parity with 17.0.9-oracle. Applies cleanly.
19-06-2023

Changeset: 5264881a Author: Alisen Chung <achung@openjdk.org> Committer: Phil Race <prr@openjdk.org> Date: 2022-06-06 21:22:38 +0000 URL: https://git.openjdk.java.net/jdk/commit/5264881a1528444dfefbabec6f42596810f0ce07
06-06-2022

WClipboard loops through all image formats when trying to set clipboard contents, but images with an alpha value cannot be encoded in jpeg. DataTransfer.imageToStandardBytesImpl checks that jpeg cannot encode images with alpha values and throws an error which is caught by WClipboard and printed.
24-05-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8871 Date: 2022-05-24 16:54:55 +0000
24-05-2022

A simple reproducer: https://gist.github.com/P0keDev/d2f7ef12fef3d320e1eec803afcdf45b This was discovered this while working on a Java-based hobby project (https://github.com/Wynntils/Artemis/pull/49). See also this Stack Overflow report on the problem: https://stackoverflow.com/questions/59140881/error-copying-an-image-object-to-the-clipboard Apparently the last change was done as part of ancient history in https://bugs.openjdk.java.net/browse/JDK-4696186, in which the exception printout were masked for certain kinds of exceptions.
10-05-2022