Check for Duration and XMLGregorianCalendar equals() method compatibility

This rule flags the use of the equals(Object param) method on javax.xml.datatype.Duration or javax.xml.datatype.XMLGregorianCalendar .

Java 6 now returns false if the parameter passed is null. It used to throw a NullPointerException. Check the application logic to see if the code needs to test for false instead of NullPointerException.

Example 1:

public MyClass extends Duration{
private void doX(){
boolean b = super.equals(someObject);
}
}

Example 2:

public MyClass {
private void doX(){
XMLGregorianCalendar c = getCalendar();
boolean b = c.equals(someObject);
}
}

In example 1, the super.equals(someObject) call will get flagged.

In example 2, the c.equals(someObject) call will get flagged.

For additional information, see item 22 in the Java SE 6 Compatibility guide.