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

DataFlavor.match(DataFlavor) throws unspecified NPE

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.5.1



      Name: sdC67446 Date: 06/30/99


      The method
          public boolean match(DataFlavor that)
      throws undocumented NullPointerException if 'this' or 'that' has been
      created with constructor DataFlavor().

      The doc says:
      --------------------------------------------------
      public boolean match(DataFlavor that)

            Two DataFlavors match if their primary types, subtypes, and
            representation classes are all equal. Additionally, if the
            primary type is "text", the charset parameter is also
            considered. If either DataFlavor is is primary type "text", but
            no charset is specified, the platform default charset is assumed
            for that DataFlavor.

      ---------Test.java--------------------------------
      import java.awt.datatransfer.*;

      public class Test {
          public static void main(String[] args) {
              try {
                  DataFlavor df1 = new DataFlavor("application/postscript;class=java.awt.Component");
                  DataFlavor df2 = new DataFlavor();
                  try {
                      System.out.println(df1.match(df2));
                  } catch (NullPointerException e) {
                      System.out.println(e);
                  }
                  try {
                      System.out.println(df2.match(df1));
                  } catch (NullPointerException e) {
                      System.out.println(e);
                  }
                  
              } catch (ClassNotFoundException e1) {
                  System.out.println(e1);
              }
          }
      }
      ---------Output-----------------------------------
      java.lang.NullPointerException
      java.lang.NullPointerException
      --------------------------------------------------
      ======================================================================

            prssunw Prs Prs (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: