JDK-6606476 : Uncatchable exception printed to console for certain clipboard contents
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-09-19
  • Updated: 2020-06-01
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
For certain types of clipboard contents (Java objects not on the classpath, for instance), an uncatchable exception is printed to the console when those contents are pasted into another Java application. For example, if you run the IntelliJ IDE and copy text onto the clipboard from within it, then startup another Java application outside of IntelliJ and press Ctrl-V to paste, you'll get:

Exception "java.lang.ClassNotFoundException: com.intellij.codeInsight.editorActi
ons.TextBlockTransferable$FoldingData"while constructing DataFlavor for: applica
tion/x-java-jvm-local-objectref; class=com.intellij.codeInsight.editorActions.Te
xtBlockTransferable$FoldingData

This exception printout is coming from SystemDataFlavor.java, line 508:

                System.err.println("Exception \"" + e.getClass().getName() +
                                   ": " + e.getMessage()  +
                                   "\"while constructing DataFlavor for: " +
                                   decoded);

The problem is that there is no way to catch this exception or suppress the printing of it, and this looks bad for the application.

It would seem that all of the System.err.printlns in SystemFlavorMap should be changed to some other form of error handling (or hidden behind a flag) so that they don't appear while running an innocent Java app.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
(1) Startup IntelliJ and copy some Java text (or otherwise, place a Java object on the clipboard by other means).
(2) From a DOS console, start the SwingSet2 application.
(3) Paste (Ctrl-V) into the Frame title text field.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected no exceptions to be printed to console.
ACTUAL -
Exceptions are printed to console:

Exception "java.lang.ClassNotFoundException: com.intellij.codeInsight.editorActi
ons.TextBlockTransferable$ReferenceData"while constructing DataFlavor for: application/x-java-jvm-local-objectref; class=com.intellij.codeInsight.editorActions.
TextBlockTransferable$ReferenceData
Exception "java.lang.ClassNotFoundException: com.intellij.codeInsight.editorActions.TextBlockTransferable$ReferenceData"while constructing DataFlavor for: application/x-java-jvm-local-objectref; class=com.intellij.codeInsight.editorActions.
TextBlockTransferable$ReferenceData
Exception "java.lang.ClassNotFoundException: com.intellij.codeInsight.editorActions.TextBlockTransferable$FoldingData"while constructing DataFlavor for: application/x-java-jvm-local-objectref; class=com.intellij.codeInsight.editorActions.Te
xtBlockTransferable$FoldingData
Exception "java.lang.ClassNotFoundException: com.intellij.codeInsight.editorActions.TextBlockTransferable$FoldingData"while constructing DataFlavor for: application/x-java-jvm-local-objectref; class=com.intellij.codeInsight.editorActions.Te
xtBlockTransferable$FoldingData

ERROR MESSAGES/STACK TRACES THAT OCCUR :
See Actual Result.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
n/a. Can be reproduced with SwingSet2 demo and another application (e.g., IntelliJ) that places a Java object on the clipboard.
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
None that I've discovered.

Comments
EVALUATION I'm not an expert in DnD, but it looks like a Java problem, not IntelliJ's (or anybody else') one. I'd suggest treating the data from clipboard as a plain text if the class required for its handling is not found, like native applications do. At the very least, the exception shouldn't be printed to the console, Logging API should be used instead.
27-09-2007