-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.3.0
-
sparc
-
solaris_2.5.1
Name: sdC67446 Date: 05/31/99
The two methods of class java.awt.datatransfer.TextFlavor
equals(String mimeString) and
equals(DataFlavor that)
throw NullPointerException for null input parameter.
Should return false;
The JLS says:
-------------------------------------------------
20.1.3 public boolean equals(Object obj)
This method indicates whether some other object is "equal to" this one.
The general contract of equals is that it implements an equivalence
relation:
It is reflexive: for any reference value x, x.equals(x) should return
true.
It is symmetric: for any reference values x and y, x.equals(y) should
return true if and only if y.equals(x) returns true.
It is transitive: for any reference values x, y, and z, if x.equals(y)
returns true and y.equals(z) returns true, then x.equals(z) should
return true.
It is consistent: for any reference values x and y, multiple
invocations of x.equals(y) consistently return true or consistently
return false, provided no information used by x and y in equals
comparisons is modified.
For any non-null reference value x, x.equals(null) should return false.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The test demonstrating the bug:
-----------------Test.java------------------------
import java.awt.datatransfer.*;
public class Test {
public static void main(String[] args) {
TextFlavor tf;
try {
tf = new TextFlavor("text/plain");
tf.equals((String)null);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NullPointerException e1) {
e1.printStackTrace();
}
try {
tf = new TextFlavor("text/plain");
tf.equals((DataFlavor)null);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NullPointerException e1) {
e1.printStackTrace();
}
};
}
---------Output-----------------------------------
java.lang.NullPointerException
at java.awt.datatransfer.MimeType.parse(MimeType.java, Compiled Code)
at java.awt.datatransfer.MimeType.<init>(MimeType.java, Compiled Code)
at java.awt.datatransfer.TextFlavor.equals(TextFlavor.java, Compiled Code)
at Test.main(Test.java, Compiled Code)
java.lang.NullPointerException
at java.awt.datatransfer.TextFlavor.equals(TextFlavor.java, Compiled Code)
at Test.main(Test.java, Compiled Code)
--------------------------------------------------
======================================================================