Thu, 10 Oct 2013 14:58:04 +0200
8001931: The new build system whitespace cleanup
Reviewed-by: tbell, simonis, erikj
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 */
11 import java.util.Comparator;
13 public class EqualsHashCodeWarningTest {
14 @Override
15 public boolean equals(Object o) {
16 return o == this;
17 }
19 @Override
20 public int hashCode() {
21 return 0;
22 }
24 public Comparator m() {
25 return new Comparator() {
26 @Override
27 public boolean equals(Object o) {return true;}
29 @Override
30 public int compare(Object o1, Object o2) {
31 return 0;
32 }
33 };
34 }
35 }
37 class SubClass extends EqualsHashCodeWarningTest {
38 @Override
39 public boolean equals(Object o) {
40 return true;
41 }
42 }
44 @SuppressWarnings("overrides")
45 class DontWarnMe {
46 @Override
47 public boolean equals(Object o) {
48 return true;
49 }
50 }
52 class DoWarnMe {
53 @Override
54 public boolean equals(Object o) {
55 return o == this;
56 }
57 }
59 abstract class IamAbstractGetMeOutOfHere {
60 public boolean equals(Object o){return true;}
61 }
63 interface I {
64 public boolean equals(Object o);
65 }
67 enum E {
68 A, B
69 }
71 @interface anno {}