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