test/tools/javac/6563143/OverridesEqualsButNotHashCodeTest.java

changeset 1588
2620c953e9fe
child 1607
bd49e0304281
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/6563143/OverridesEqualsButNotHashCodeTest.java	Mon Feb 18 14:33:25 2013 +0000
     1.3 @@ -0,0 +1,22 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 6563143
     1.7 + * @summary javac should issue a warning for overriding equals without hashCode
     1.8 + * @compile/ref=OverridesEqualsButNotHashCodeTest.out -Xlint:overrides -XDrawDiagnostics OverridesEqualsButNotHashCodeTest.java
     1.9 + */
    1.10 +
    1.11 +@SuppressWarnings("overrides")
    1.12 +public class OverridesEqualsButNotHashCodeTest {
    1.13 +    @Override
    1.14 +    public boolean equals(Object o) {
    1.15 +        return o == this;
    1.16 +    }
    1.17 +}
    1.18 +
    1.19 +class Other {
    1.20 +    @Override
    1.21 +    public boolean equals(Object o) {
    1.22 +        return o == this;
    1.23 +    }
    1.24 +}
    1.25 +

mercurial