Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/langtools/tools/javac/6563143/EqualsHashCodeWarningTest.java
41152 views
1
/*
2
* @test /nodynamiccopyright/
3
* @bug 6563143 8008436 8009138
4
* @summary javac should issue a warning for overriding equals without hashCode
5
* @summary javac should not issue a warning for overriding equals without hasCode
6
* @summary javac, equals-hashCode warning tuning
7
* if hashCode has been overriden by a superclass
8
* @compile/ref=EqualsHashCodeWarningTest.out -Xlint:overrides -XDrawDiagnostics EqualsHashCodeWarningTest.java
9
*/
10
11
import java.util.Comparator;
12
13
public class EqualsHashCodeWarningTest {
14
@Override
15
public boolean equals(Object o) {
16
return o == this;
17
}
18
19
@Override
20
public int hashCode() {
21
return 0;
22
}
23
24
public Comparator m() {
25
return new Comparator() {
26
@Override
27
public boolean equals(Object o) {return true;}
28
29
@Override
30
public int compare(Object o1, Object o2) {
31
return 0;
32
}
33
};
34
}
35
}
36
37
class SubClass extends EqualsHashCodeWarningTest {
38
@Override
39
public boolean equals(Object o) {
40
return true;
41
}
42
}
43
44
@SuppressWarnings("overrides")
45
class DontWarnMe {
46
@Override
47
public boolean equals(Object o) {
48
return true;
49
}
50
}
51
52
class DoWarnMe {
53
@Override
54
public boolean equals(Object o) {
55
return o == this;
56
}
57
}
58
59
abstract class IamAbstractGetMeOutOfHere {
60
public boolean equals(Object o){return true;}
61
}
62
63
interface I {
64
public boolean equals(Object o);
65
}
66
67
enum E {
68
A, B
69
}
70
71
@interface anno {}
72
73