I recently discovered that class ProcessBuilder in JDK6 does not override equals()
. Is there a reason? Since the class is mutable, I can understand why it does not override hashCode()
.
I was surprised to see this code not work:
ProcessBuilder x = new ProcessBuilder("abc", "def");
ProcessBuilder y = new ProcessBuilder("abc", "def");
if (x.equals(y)) { // they are never equal
// something important here
}
I looked into the JDK6 source code for class ProcessBuilder
, and I do not see an override for equals()
.
I have a feeling there is a deeper reason, beyond this one class. Perhaps this is intentional?