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

A null pointer exception occurs calling 'isDataFlavorSupported' on Solaris

XMLWordPrintable

    • 1.2beta4
    • sparc
    • solaris_2.5.1
    • Verified

      mark.lin@Eng 1998-05-18

      If you call Transferable.isDataFlavorSupported() with a custom dataFlavor and there is a X11Selection currently on the system clipboard, you get a null pointer exception. This only occurs on Solaris, not NT.

      java.lang.NullPointerException
              at sun.awt.motif.X11Selection.isDataFlavorSupported(X11Selection.java:223)
              at TestClip.<init>(TestClip.java:39)
              at TestClip.main(TestClip.java:49)

      Attached is code to reproduce this bug.

      /**
       * This program demonstrates a null pointer exception bug that occurs whenever
       * you call Transferable.isFlavorSupported() using a custom dataflavor and
       * there is currently a X11Selection transfer on the system clipboard.
       * This bug only occurs on Solaris.
       * Here is how you run it:
       * Before starting the program, place text onto the system clipboard through
       * some third party application (ie. copy some text from xemacs). Now start
       * the program by typing 'java TestClip'. Note that you get:
       * java.lang.NullPointerException
       * at sun.awt.motif.X11Selection.isDataFlavorSupported(X11Selection.java:223)
       * at TestClip.<init>(TestClip.java:20)
       * at TestClip.main(TestClip.java:26)
       */

      import java.lang.*;
      import java.io.*;
      import java.awt.*;
      import java.awt.datatransfer.*;

      public class TestClip extends Object {

          class MyFlavor extends Object implements Serializable {
              // Stub class needed in order to define the data flavor type
          }

          public TestClip () {
              // Create an arbitrary dataflavor
              DataFlavor myFlavor = new DataFlavor(MyFlavor.class, "TestClip");
              // Get the system clipboard
              Clipboard theClipboard =
                  Toolkit.getDefaultToolkit().getSystemClipboard();
              // Get the current contents of the clipboard
              Transferable theTransfer = theClipboard.getContents(this);

              // See if the flavor is supported. This will result in a null
              // pointer exception on Solaris, but not NT
              boolean isSupported = theTransfer.isDataFlavorSupported(myFlavor);

              System.exit(1);

          }

          public static void main(String argv[]) {
              // Create a new TestClip class
              new TestClip();
          }

      }

            jwarzech Joe Warzecha (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: