equals() and hashCode() implementations should rely only on an internal object state. Making them dependent on other objects, context of use and other external conditions conflicts with the general contracts of consistency:
“For any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false” [*]
“Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer” [*]
Violating those contracts may cause all kinds of weird and unpredictable behavior.
A known example of this antipattern is equals() and hashCode() in java.net.URL implementation where they are depending on information returned by a domain name server, rather than on actual stored URL data.
See also: