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

REGRESSION: Clipboard().setContents from JDK1.3.1 onwards does not work

XMLWordPrintable

    • mantis
    • x86
    • windows_2000
    • Verified



      Name: gm110360 Date: 05/08/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      and

      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)


      FULL OPERATING SYSTEM VERSION :

      Microsoft Windows 2000 [5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      My application cut/copy/paste feature is failing when an
      attempt is made to place a (Transferable) object on the
      clipboard. This used to work fine in 1.3, and began
      failing when I upgraded to 1.4.


      REGRESSION. Last worked in version 1.3.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run my sample program in 1.3 - it works.
      2. Run the same program in 1.4 - it gets an exception when
      the clipboard's setContents method is called.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The program should run in 1.4.



      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      When I run my test case program in 1.4, I get the following Exception trace:

      Exception in thread "main" java.lang.NullPointerException
              at sun.awt.datatransfer.DataTransferer.getFormatsForFlavors(DataTransfer
      er.java:719)
              at sun.awt.windows.WDataTransferer.getFormatsForFlavors(WDataTransferer.
      java:127)
              at sun.awt.datatransfer.DataTransferer.getFormatsForTransferable(DataTra
      nsferer.java:687)
              at sun.awt.windows.WClipboard.setContents(WClipboard.java:63)
              at CBTest.main(CBTest.java:10)


      In my application, the setContents method also fails, but gives a different
      excetption trace:

      java.lang.ClassCastException: java.lang.Object
      at sun.awt.datatransfer.DataTransferer.translateTransferable
      (DataTransferer.java:1214)
      at sun.awt.windows.WDataTransferer.translateTransferable
      (WDataTransferer.java:144)
      at sun.awt.windows.WClipboard.setContents(WClipboard.java:75)


      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.datatransfer.*;
      import java.awt.*;
      import javax.swing.*;

      public class CBTest {

      public static void main(String[] args) {

      TransferableSample transferableSample = new TransferableSample
      ();
      Toolkit.getDefaultToolkit().getSystemClipboard().setContents
      (transferableSample,transferableSample);
      System.out.println("Success");

         }

      static public class TransferableSample implements Transferable, ClipboardOwner {

      public DataFlavor imageFlavor;
      private DataFlavor [] supportedFlavors = {imageFlavor};
      private Image picture ;

      public TransferableSample () {

          picture = new ImageIcon("wo.gif").getImage();

          try {
          imageFlavor = new DataFlavor (Class.forName
      ("java.awt.Image"), "Image");
               }
              catch (ClassNotFoundException e) {
          e.printStackTrace ();
          }

          }
         
          public synchronized DataFlavor [] getTransferDataFlavors () {
       
          return (supportedFlavors);
         
          }
         
          public boolean isDataFlavorSupported (DataFlavor parFlavor) {
         
          return (parFlavor.equals (imageFlavor));
         
          }
         
          public synchronized Object getTransferData (DataFlavor parFlavor)
          throws UnsupportedFlavorException {
          if (parFlavor.equals (imageFlavor))
          return (picture);
          else
          throw new UnsupportedFlavorException (imageFlavor);
         
          }
         
          public void lostOwnership (Clipboard parClipboard, Transferable
      parTransferable) {
         
              System.out.println ("Lost ownership");

      }
      }
      }
      ---------- END SOURCE ----------

      Release Regression From : 1.3.0_05
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Review ID: 146336)
      ======================================================================

            agerasimsunw Alexander Gerasimov (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: