- Notifications
You must be signed in to change notification settings - Fork 6.3k
Description
All module classes that support jspecify (and will support it in the future) must have @Nullable in their equals method.
I believe this is necessary for several reasons. The main one is that the Object.equals contract itself can always accept null, and we're removing this. This leads to bugs like #18927. For example, in this specific issue, the Kotlin compiler can't correctly resolve the equals signature.
Examples are readily available. In Spring projects, this has already been implemented at the very beginning of jspecify implementation. For example:
Spring Framework:
https://github.com/spring-projects/spring-framework/blob/main/spring-core/src/main/java/org/springframework/util/comparator/BooleanComparator.java#L74
https://github.com/spring-projects/spring-framework/blob/main/spring-web/src/main/java/org/springframework/http/HttpHeaders.java#L2066
We should fix this and take this into account in the future when adding jspecify support to other modules.
Relates: #18927