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

java.awt.datatransfer.DataFlavor.equals throws NullPointerException

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2.2
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: sdC67446 Date: 09/22/98


      The methods equals(DataFlavor df), equals(String mt), equals(Object
      mt) of class java.awt.datatransfer.DataFlavor throw
      NullPointerException if class instance was created with constructor
      DataFlavor().

      The doc says:
      --------------------------------------------------
      public boolean equals(DataFlavor dataFlavor)
            Returns:
                  if the DataFlavors represent the same type.

      public boolean equals(java.lang.Object o)
            Returns:
                  if the objects are equal
            Overrides:
                  equals in class java.lang.Object

      public boolean equals(java.lang.String s)
            Returns:
                  if the String (MimeType) is equal

      Here is the test demonstrating the bug:
      -----------------Test.java------------------------
      import java.awt.datatransfer.*;

      public class Test {
            public static void main(String[] args) {
      DataFlavor df = new DataFlavor();
      try {
      System.out.println(df.equals((Object)new DataFlavor()));
      } catch (Exception e) {
      System.out.println("equals(Object): "+e);
      }

      try {
      System.out.println(df.equals(new DataFlavor()));
      } catch (Exception e) {
      System.out.println("equals(DataFlavor): "+e);
      }

      try {
      System.out.println(df.equals("application/postscript;class=java.awt.datatransfer.DataFlavor"));
      } catch (Exception e) {
      System.out.println("equals(String) "+e);
      }
          }
      }
      ---------Output from the test---------------------
      equals(Object): java.lang.NullPointerException
      equals(DataFlavor): java.lang.NullPointerException
      equals(String): java.lang.NullPointerException
      --------------------------------------------------
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                prssunw Prs Prs (Inactive)
                Reporter:
                sdmitriesunw Sergei Dmitriev (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: