diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm index 2c26d472fbe..ed64fa2128a 100755 --- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm +++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm @@ -624,7 +624,7 @@ public class ${this.mangleTypeIdentifier($schema.getName())} extends ${this.getS #foreach ($field in $schema.getFields()) #if (!${this.ignoredField($field)}) #set ($n = ${this.mangle($field.name(), $schema.isError())}) - result = 31 * result + ${this.hashCodeFor($field.schema(), $n)}; + result = 31 * result + ${this.hashCodeFor($field.schema(), "this." + $n)}; #end #end return result; diff --git a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/FieldTest.java b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/FieldTest.java index 8799e202fc7..9948bfda09f 100644 --- a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/FieldTest.java +++ b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/FieldTest.java @@ -665,12 +665,12 @@ public FieldTest build() { @Override public int hashCode() { int result = 1; - result = 31 * result + Integer.hashCode(number); - result = 31 * result + (last_name == null ? 0 : last_name.hashCode()); - result = 31 * result + (timestamp == null ? 0 : timestamp.hashCode()); - result = 31 * result + (timestampMicros == null ? 0 : timestampMicros.hashCode()); - result = 31 * result + (timeMillis == null ? 0 : timeMillis.hashCode()); - result = 31 * result + (timeMicros == null ? 0 : timeMicros.hashCode()); + result = 31 * result + Integer.hashCode(this.number); + result = 31 * result + (this.last_name == null ? 0 : this.last_name.hashCode()); + result = 31 * result + (this.timestamp == null ? 0 : this.timestamp.hashCode()); + result = 31 * result + (this.timestampMicros == null ? 0 : this.timestampMicros.hashCode()); + result = 31 * result + (this.timeMillis == null ? 0 : this.timeMillis.hashCode()); + result = 31 * result + (this.timeMicros == null ? 0 : this.timeMicros.hashCode()); return result; } diff --git a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/JSpecifyNullSafeAnnotationsFieldsTest.java b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/JSpecifyNullSafeAnnotationsFieldsTest.java index e99e04dc526..b03eb764480 100644 --- a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/JSpecifyNullSafeAnnotationsFieldsTest.java +++ b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/JSpecifyNullSafeAnnotationsFieldsTest.java @@ -585,10 +585,10 @@ public JSpecifyNullSafeAnnotationsFieldsTest build() { @Override public int hashCode() { int result = 1; - result = 31 * result + (name == null ? 0 : name.hashCode()); - result = 31 * result + (nullable_name == null ? 0 : nullable_name.hashCode()); - result = 31 * result + Integer.hashCode(favorite_number); - result = 31 * result + (nullable_favorite_number == null ? 0 : nullable_favorite_number.hashCode()); + result = 31 * result + (this.name == null ? 0 : this.name.hashCode()); + result = 31 * result + (this.nullable_name == null ? 0 : this.nullable_name.hashCode()); + result = 31 * result + Integer.hashCode(this.favorite_number); + result = 31 * result + (this.nullable_favorite_number == null ? 0 : this.nullable_favorite_number.hashCode()); return result; } diff --git a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/JetBrainsNullSafeAnnotationsFieldsTest.java b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/JetBrainsNullSafeAnnotationsFieldsTest.java index 7df11818f5e..46354b0ffba 100644 --- a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/JetBrainsNullSafeAnnotationsFieldsTest.java +++ b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/JetBrainsNullSafeAnnotationsFieldsTest.java @@ -585,10 +585,10 @@ public JetBrainsNullSafeAnnotationsFieldsTest build() { @Override public int hashCode() { int result = 1; - result = 31 * result + (name == null ? 0 : name.hashCode()); - result = 31 * result + (nullable_name == null ? 0 : nullable_name.hashCode()); - result = 31 * result + Integer.hashCode(favorite_number); - result = 31 * result + (nullable_favorite_number == null ? 0 : nullable_favorite_number.hashCode()); + result = 31 * result + (this.name == null ? 0 : this.name.hashCode()); + result = 31 * result + (this.nullable_name == null ? 0 : this.nullable_name.hashCode()); + result = 31 * result + Integer.hashCode(this.favorite_number); + result = 31 * result + (this.nullable_favorite_number == null ? 0 : this.nullable_favorite_number.hashCode()); return result; } diff --git a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java index 79fc55dbf9a..ea390e8445d 100644 --- a/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java +++ b/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java @@ -593,10 +593,10 @@ public Player build() { @Override public int hashCode() { int result = 1; - result = 31 * result + Integer.hashCode(number); - result = 31 * result + (first_name == null ? 0 : first_name.hashCode()); - result = 31 * result + (last_name == null ? 0 : last_name.hashCode()); - result = 31 * result + (position == null ? 0 : position.hashCode()); + result = 31 * result + Integer.hashCode(this.number); + result = 31 * result + (this.first_name == null ? 0 : this.first_name.hashCode()); + result = 31 * result + (this.last_name == null ? 0 : this.last_name.hashCode()); + result = 31 * result + (this.position == null ? 0 : this.position.hashCode()); return result; } diff --git a/lang/java/tools/src/test/compiler/output/AddExtraOptionalGettersTest.java b/lang/java/tools/src/test/compiler/output/AddExtraOptionalGettersTest.java index 328091ac8bc..2579c8f73d1 100644 --- a/lang/java/tools/src/test/compiler/output/AddExtraOptionalGettersTest.java +++ b/lang/java/tools/src/test/compiler/output/AddExtraOptionalGettersTest.java @@ -434,8 +434,8 @@ public AddExtraOptionalGettersTest build() { @Override public int hashCode() { int result = 1; - result = 31 * result + (name == null ? 0 : name.hashCode()); - result = 31 * result + (favorite_number == null ? 0 : favorite_number.hashCode()); + result = 31 * result + (this.name == null ? 0 : this.name.hashCode()); + result = 31 * result + (this.favorite_number == null ? 0 : this.favorite_number.hashCode()); return result; } diff --git a/lang/java/tools/src/test/compiler/output/NoSettersTest.java b/lang/java/tools/src/test/compiler/output/NoSettersTest.java index 92c91854cff..2f75aaa9b04 100644 --- a/lang/java/tools/src/test/compiler/output/NoSettersTest.java +++ b/lang/java/tools/src/test/compiler/output/NoSettersTest.java @@ -392,8 +392,8 @@ public NoSettersTest build() { @Override public int hashCode() { int result = 1; - result = 31 * result + (name == null ? 0 : name.hashCode()); - result = 31 * result + (favorite_number == null ? 0 : favorite_number.hashCode()); + result = 31 * result + (this.name == null ? 0 : this.name.hashCode()); + result = 31 * result + (this.favorite_number == null ? 0 : this.favorite_number.hashCode()); return result; } diff --git a/lang/java/tools/src/test/compiler/output/OptionalGettersAllFieldsTest.java b/lang/java/tools/src/test/compiler/output/OptionalGettersAllFieldsTest.java index 0194aeaed02..97964e0661b 100644 --- a/lang/java/tools/src/test/compiler/output/OptionalGettersAllFieldsTest.java +++ b/lang/java/tools/src/test/compiler/output/OptionalGettersAllFieldsTest.java @@ -497,10 +497,10 @@ public OptionalGettersAllFieldsTest build() { @Override public int hashCode() { int result = 1; - result = 31 * result + (name == null ? 0 : name.hashCode()); - result = 31 * result + (nullable_name == null ? 0 : nullable_name.hashCode()); - result = 31 * result + (favorite_number == null ? 0 : favorite_number.hashCode()); - result = 31 * result + (nullable_favorite_number == null ? 0 : nullable_favorite_number.hashCode()); + result = 31 * result + (this.name == null ? 0 : this.name.hashCode()); + result = 31 * result + (this.nullable_name == null ? 0 : this.nullable_name.hashCode()); + result = 31 * result + (this.favorite_number == null ? 0 : this.favorite_number.hashCode()); + result = 31 * result + (this.nullable_favorite_number == null ? 0 : this.nullable_favorite_number.hashCode()); return result; } diff --git a/lang/java/tools/src/test/compiler/output/OptionalGettersNullableFieldsTest.java b/lang/java/tools/src/test/compiler/output/OptionalGettersNullableFieldsTest.java index ad9b9c38636..162e5fac601 100644 --- a/lang/java/tools/src/test/compiler/output/OptionalGettersNullableFieldsTest.java +++ b/lang/java/tools/src/test/compiler/output/OptionalGettersNullableFieldsTest.java @@ -569,11 +569,11 @@ public OptionalGettersNullableFieldsTest build() { @Override public int hashCode() { int result = 1; - result = 31 * result + (name == null ? 0 : name.hashCode()); - result = 31 * result + (nullable_name == null ? 0 : nullable_name.hashCode()); - result = 31 * result + (favorite_number == null ? 0 : favorite_number.hashCode()); - result = 31 * result + (nullable_favorite_number == null ? 0 : nullable_favorite_number.hashCode()); - result = 31 * result + (nullable_array == null ? 0 : nullable_array.hashCode()); + result = 31 * result + (this.name == null ? 0 : this.name.hashCode()); + result = 31 * result + (this.nullable_name == null ? 0 : this.nullable_name.hashCode()); + result = 31 * result + (this.favorite_number == null ? 0 : this.favorite_number.hashCode()); + result = 31 * result + (this.nullable_favorite_number == null ? 0 : this.nullable_favorite_number.hashCode()); + result = 31 * result + (this.nullable_array == null ? 0 : this.nullable_array.hashCode()); return result; } diff --git a/lang/java/tools/src/test/compiler/output/Player.java b/lang/java/tools/src/test/compiler/output/Player.java index adc1e2be7fa..1c2d61e2db8 100644 --- a/lang/java/tools/src/test/compiler/output/Player.java +++ b/lang/java/tools/src/test/compiler/output/Player.java @@ -593,10 +593,10 @@ public Player build() { @Override public int hashCode() { int result = 1; - result = 31 * result + Integer.hashCode(number); - result = 31 * result + (first_name == null ? 0 : first_name.hashCode()); - result = 31 * result + (last_name == null ? 0 : last_name.hashCode()); - result = 31 * result + (position == null ? 0 : position.hashCode()); + result = 31 * result + Integer.hashCode(this.number); + result = 31 * result + (this.first_name == null ? 0 : this.first_name.hashCode()); + result = 31 * result + (this.last_name == null ? 0 : this.last_name.hashCode()); + result = 31 * result + (this.position == null ? 0 : this.position.hashCode()); return result; }