Skip to content

Detect overriding only one of equals or hashCode. #129

Closed

Description

@cushon

Original issue created by dweis@google.com on 2013-05-01 at 10:19 PM


Forcing it to be an error makes the developer have to add an implementation that delegates to super but at least it's not a conscious decision.

Bad:

class MyClass {

  @Override
  public boolean equals(Object o) {
    return true;
  }
}
class MyClass {

  @Override
    public int hashCode() {
      return 42;
  }
}

Good:

class MyClass {

  @Override
  public boolean equals(Object o) {
    return true;
  }

  @Override
  public int hashCode() {
    return 42;
  }
}

This, in conjunction with a solution to #35, should provide adequate protection for developers.

Activity

  1. cushon commented on Oct 31, 2014

    @cushon
    CollaboratorAuthor

    Original comment posted by aeagle22206 on 2013-08-12 at 09:09 PM


    Issue #157 has been merged into this issue.

  2. cushon commented on Oct 31, 2014

    @cushon
    CollaboratorAuthor

    Original comment posted by eaftan@google.com on 2014-04-08 at 08:55 PM


    (No comment entered for this change.)


    Status: Accepted
    Owner: cushon@google.com

  3. self-assigned this
    on Feb 3, 2015
  4. added 2 commits that reference this issue on Feb 13, 2015
    d8edf24
    17db22d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions