You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AVRO-4202: Refer to fields for generated hashCode (#3547)
The generated hashCode function has a local parameter called result.
To prevent this local variable to conflict with field which have the
same name, it has to refer to the fields with `this.<fieldName>` making
it unambiguous refer to fields and not local variables.
Copy file name to clipboardExpand all lines: lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/JSpecifyNullSafeAnnotationsFieldsTest.java
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -585,10 +585,10 @@ public JSpecifyNullSafeAnnotationsFieldsTest build() {
585
585
@Override
586
586
publicinthashCode() {
587
587
intresult = 1;
588
-
result = 31 * result + (name == null ? 0 : name.hashCode());
589
-
result = 31 * result + (nullable_name == null ? 0 : nullable_name.hashCode());
590
-
result = 31 * result + Integer.hashCode(favorite_number);
591
-
result = 31 * result + (nullable_favorite_number == null ? 0 : nullable_favorite_number.hashCode());
588
+
result = 31 * result + (this.name == null ? 0 : this.name.hashCode());
589
+
result = 31 * result + (this.nullable_name == null ? 0 : this.nullable_name.hashCode());
590
+
result = 31 * result + Integer.hashCode(this.favorite_number);
591
+
result = 31 * result + (this.nullable_favorite_number == null ? 0 : this.nullable_favorite_number.hashCode());
Copy file name to clipboardExpand all lines: lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/JetBrainsNullSafeAnnotationsFieldsTest.java
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -585,10 +585,10 @@ public JetBrainsNullSafeAnnotationsFieldsTest build() {
585
585
@Override
586
586
publicinthashCode() {
587
587
intresult = 1;
588
-
result = 31 * result + (name == null ? 0 : name.hashCode());
589
-
result = 31 * result + (nullable_name == null ? 0 : nullable_name.hashCode());
590
-
result = 31 * result + Integer.hashCode(favorite_number);
591
-
result = 31 * result + (nullable_favorite_number == null ? 0 : nullable_favorite_number.hashCode());
588
+
result = 31 * result + (this.name == null ? 0 : this.name.hashCode());
589
+
result = 31 * result + (this.nullable_name == null ? 0 : this.nullable_name.hashCode());
590
+
result = 31 * result + Integer.hashCode(this.favorite_number);
591
+
result = 31 * result + (this.nullable_favorite_number == null ? 0 : this.nullable_favorite_number.hashCode());
0 commit comments