File: EqualsHashCodeWarningTest.java

package info (click to toggle)
libnb-javaparser-java 7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 35,940 kB
  • ctags: 55,696
  • sloc: java: 264,137; xml: 2,781; sh: 1,135; makefile: 425
file content (71 lines) | stat: -rw-r--r-- 1,508 bytes parent folder | download | duplicates (23)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * @test /nodynamiccopyright/
 * @bug 6563143 8008436 8009138
 * @summary javac should issue a warning for overriding equals without hashCode
 * @summary javac should not issue a warning for overriding equals without hasCode
 * @summary javac, equals-hashCode warning tuning
 * if hashCode has been overriden by a superclass
 * @compile/ref=EqualsHashCodeWarningTest.out -Xlint:overrides -XDrawDiagnostics EqualsHashCodeWarningTest.java
 */

import java.util.Comparator;

public class EqualsHashCodeWarningTest {
    @Override
    public boolean equals(Object o) {
        return o == this;
    }

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

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

            @Override
            public int compare(Object o1, Object o2) {
                return 0;
            }
        };
    }
}

class SubClass extends EqualsHashCodeWarningTest {
    @Override
    public boolean equals(Object o) {
        return true;
    }
}

@SuppressWarnings("overrides")
class DontWarnMe {
    @Override
    public boolean equals(Object o) {
        return true;
    }
}

class DoWarnMe {
    @Override
    public boolean equals(Object o) {
        return o == this;
    }
}

abstract class IamAbstractGetMeOutOfHere {
    public boolean equals(Object o){return true;}
}

interface I {
    public boolean equals(Object o);
}

enum E {
    A, B
}

@interface anno {}