JDK-6255835 : TransferHandler.pasteAction should not use Clipboard.getContents() for performance reasons
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P5
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2005-04-15
  • Updated: 2013-05-15
Related Reports
Relates :  
Relates :  
Relates :  
Description
TransferHandler's paste action uses Clipboard.getContents()
to retrieve a Transferable from the clipboard and pass it to
TransferHandler.importData(). Clipboard.getContents() is known
to be quite expensive as it fetches data in all available flavors:
refer to the bug 4790833(Memory usage shoots way up using
Clipboard.getContents()) which was fixed in tiger. On the other
part, data in only one flavor are pasted typically.

The fix for 4790833 introduced new Clipboard methods:
getAvailableDataFlavors(), isDataFlavorAvailable() and
getData() that allows to fetch data for only one flavor.

So I propose to make use of these Clipboard methods in the
implementation of TransferHandler's paste action.

###@###.### 2005-04-15 10:05:54 GMT

Comments
SUGGESTED FIX TransferHandler creates a special Transferable that uses Clipboard's methods getAvailableDataFlavors(), isDataFlavorAvailable() and getData(). Transferable's getTransferDataFlavors() calls into Clipboard.getAvailableDataFlavors(), isDataFlavorSupported() calls into Clipboard.isDataFlavorAvailable() and getTransferData() calls into Clipboard.getData(). ###@###.### 2005-04-15 10:05:55 GMT
15-04-2005

EVALUATION This is definitely something worth investigating for a future performance enhancement. ###@###.### 2005-07-20 21:00:27 GMT
15-04-2005