Skip to content

Commit 075cc80

Browse files
Andy Goryachevnlisker
authored andcommitted
8289389: Fix warnings: type should also implement hashCode() since it overrides Object.equals()
Reviewed-by: kcr
1 parent 9f636da commit 075cc80

File tree

9 files changed

+83
-11
lines changed

9 files changed

+83
-11
lines changed

modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1715,6 +1715,11 @@ public RT22599_DataType(int id, String text) {
17151715
if (obj == null) return false;
17161716
return id == ((RT22599_DataType)obj).id;
17171717
}
1718+
1719+
@Override
1720+
public int hashCode() {
1721+
return id;
1722+
}
17181723
}
17191724

17201725
private int rt_39966_count = 0;

modules/javafx.controls/src/test/java/test/javafx/scene/control/TableViewTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -5086,6 +5086,11 @@ public RT22599_DataType(int id, String text) {
50865086
if (obj == null) return false;
50875087
return id == ((RT22599_DataType)obj).id;
50885088
}
5089+
5090+
@Override
5091+
public int hashCode() {
5092+
return id;
5093+
}
50895094
}
50905095

50915096
private int rt_39966_count = 0;

modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -5754,6 +5754,11 @@ public RT22599_DataType(int id, String text) {
57545754
if (obj == null) return false;
57555755
return id == ((RT22599_DataType)obj).id;
57565756
}
5757+
5758+
@Override
5759+
public int hashCode() {
5760+
return id;
5761+
}
57575762
}
57585763

57595764
private int rt_39966_count = 0;

modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeViewTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -3076,6 +3076,11 @@ public RT22599_DataType(int id, String text) {
30763076
if (obj == null) return false;
30773077
return id == ((RT22599_DataType)obj).id;
30783078
}
3079+
3080+
@Override
3081+
public int hashCode() {
3082+
return id;
3083+
}
30793084
}
30803085

30813086
private int rt_39966_count = 0;

modules/javafx.fxml/src/main/java/javafx/fxml/FXMLLoader.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -2321,6 +2321,13 @@ public boolean equals(Object obj) {
23212321
return false;
23222322
}
23232323

2324+
@Override
2325+
public int hashCode() {
2326+
int h = FXMLLoader.class.hashCode();
2327+
h = 31 * h + (location == null ? 0 : location.toExternalForm().hashCode());
2328+
return h;
2329+
}
2330+
23242331
private boolean isCyclic(
23252332
FXMLLoader currentLoader,
23262333
FXMLLoader node) {

modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/IntSet.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -152,6 +152,15 @@ public boolean equals(Object o) {
152152
}
153153
}
154154

155+
@Override
156+
public int hashCode() {
157+
int h = 1;
158+
for (int i = 0; i < size; i++) {
159+
h = 31 * h + elements[i];
160+
}
161+
return h;
162+
}
163+
155164
public String toString() {
156165
StringBuffer sb = new StringBuffer("IntSet[");
157166
for (int i = 0; i < size; i++) {

modules/javafx.graphics/src/main/java/com/sun/javafx/css/CalculatedValue.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,15 @@ public boolean isRelative() {
8888
return true;
8989
}
9090

91+
@Override
92+
public int hashCode() {
93+
int h = CalculatedValue.class.hashCode();
94+
h = 31 * h + Boolean.hashCode(relative);
95+
h = 31 * h + (origin == null ? 0 : origin.hashCode());
96+
h = 31 * h + (value == null ? 0 : value.hashCode());
97+
return h;
98+
}
99+
91100
private final Object value;
92101
private final StyleOrigin origin;
93102
private final boolean relative;

modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/NativeMediaAudioClipPlayer.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -425,8 +425,8 @@ public void onError(Object source, int errorCode, String message) {
425425
}
426426

427427
/*
428-
* Override equals for using in a List of clips pended for pllayback.
429-
* Equals is used to avoid repetitions. hashCode is not necessary here.
428+
* Override equals for using in a List of clips pended for playback.
429+
* Equals is used to avoid repetitions.
430430
*/
431431
@Override
432432
public boolean equals(Object that) {
@@ -451,6 +451,19 @@ public boolean equals(Object that) {
451451
}
452452
}
453453

454+
@Override
455+
public int hashCode() {
456+
int h = NativeMediaAudioClipPlayer.class.hashCode();
457+
h = 31 * h + sourceClip.getLocator().getURI().hashCode();
458+
h = 31 * h + priority;
459+
h = 31 * h + loopCount;
460+
h = 31 * h + Double.hashCode(volume);
461+
h = 31 * h + Double.hashCode(balance);
462+
h = 31 * h + Double.hashCode(rate);
463+
h = 31 * h + Double.hashCode(pan);
464+
return h;
465+
}
466+
454467
private static class SchedulerEntry {
455468
private final int command; // 0 = play, 1 = stop, 2 = dispose
456469
private final NativeMediaAudioClipPlayer player; // MAY BE NULL!
@@ -517,5 +530,10 @@ public void signal() {
517530
}
518531
return false;
519532
}
533+
534+
@Override
535+
public int hashCode() {
536+
return player == null ? 0 : player.hashCode();
537+
}
520538
}
521539
}

modules/javafx.web/src/main/java/com/sun/webkit/graphics/WCRectangle.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -260,6 +260,15 @@ public boolean equals(Object obj) {
260260
return super.equals(obj);
261261
}
262262

263+
@Override
264+
public int hashCode() {
265+
int h = WCRectangle.class.hashCode();
266+
h = 31 * h + Float.floatToIntBits(x);
267+
h = 31 * h + Float.floatToIntBits(y);
268+
h = 31 * h + Float.floatToIntBits(w);
269+
return 31 * h + Float.floatToIntBits(h);
270+
}
271+
263272
@Override
264273
public String toString() {
265274
return "WCRectangle{x:" + x + " y:" + y + " w:" + w + " h:" + h + "}";

0 commit comments

Comments
 (0)