aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2014-01-09 21:00:44 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2014-01-09 21:24:04 +0100
commita40a86ad532881acd311200a665b5f55790c55cc (patch)
tree653880e9aa8078c42a86cf0a7a184bd040e87308
parent685ddfd52ebba4ca85ff93e08de14f38ecd8714b (diff)
downloadlombok-a40a86ad532881acd311200a665b5f55790c55cc.tar.gz
lombok-a40a86ad532881acd311200a665b5f55790c55cc.tar.bz2
lombok-a40a86ad532881acd311200a665b5f55790c55cc.zip
[#625] Instead of '31' as a prime number for hashCode(), use something else. 31, probably owing to its inclusion in Effective Java, is overused, as proven by Maaartinus in issue 625. Switching to 277 instead. Also, 1231/1237 pair used for booleans has been replaced by 2591/2609.
-rw-r--r--src/core/lombok/core/handlers/HandlerUtil.java6
-rw-r--r--src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java17
-rw-r--r--src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java10
-rw-r--r--test/transform/resource/after-delombok/Accessors.java2
-rw-r--r--test/transform/resource/after-delombok/DataExtended.java2
-rw-r--r--test/transform/resource/after-delombok/DataIgnore.java2
-rw-r--r--test/transform/resource/after-delombok/DataOnLocalClass.java6
-rw-r--r--test/transform/resource/after-delombok/DataPlain.java8
-rw-r--r--test/transform/resource/after-delombok/DataWithGetter.java2
-rw-r--r--test/transform/resource/after-delombok/DataWithGetterNone.java2
-rw-r--r--test/transform/resource/after-delombok/EqualsAndHashCode.java6
-rw-r--r--test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java2
-rw-r--r--test/transform/resource/after-delombok/GetterLazyBoolean.java4
-rw-r--r--test/transform/resource/after-delombok/GetterLazyEahcToString.java2
-rw-r--r--test/transform/resource/after-delombok/GetterSetterJavadoc.java2
-rw-r--r--test/transform/resource/after-delombok/ValuePlain.java6
-rw-r--r--test/transform/resource/after-ecj/Accessors.java2
-rw-r--r--test/transform/resource/after-ecj/DataExtended.java2
-rw-r--r--test/transform/resource/after-ecj/DataIgnore.java2
-rw-r--r--test/transform/resource/after-ecj/DataOnLocalClass.java6
-rw-r--r--test/transform/resource/after-ecj/DataPlain.java8
-rw-r--r--test/transform/resource/after-ecj/DataWithGetter.java2
-rw-r--r--test/transform/resource/after-ecj/DataWithGetterNone.java2
-rw-r--r--test/transform/resource/after-ecj/EqualsAndHashCode.java6
-rw-r--r--test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java2
-rw-r--r--test/transform/resource/after-ecj/GetterLazyBoolean.java4
-rw-r--r--test/transform/resource/after-ecj/GetterLazyEahcToString.java2
-rw-r--r--test/transform/resource/after-ecj/GetterSetterJavadoc.java2
-rw-r--r--test/transform/resource/after-ecj/ValuePlain.java6
-rw-r--r--usage_examples/DataExample_post.jpage4
-rw-r--r--usage_examples/EqualsAndHashCodeExample_post.jpage4
-rw-r--r--usage_examples/ValueExample_post.jpage4
32 files changed, 72 insertions, 65 deletions
diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java
index 3d386054..c8076ab6 100644
--- a/src/core/lombok/core/handlers/HandlerUtil.java
+++ b/src/core/lombok/core/handlers/HandlerUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 The Project Lombok Authors.
+ * Copyright (C) 2013-2014 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -27,6 +27,10 @@ import lombok.core.LombokNode;
public class HandlerUtil {
private HandlerUtil() {}
+ public static final int PRIME_FOR_HASHCODE = 277;
+ public static final int PRIME_FOR_TRUE = 2591;
+ public static final int PRIME_FOR_FALSE = 2609;
+
/** Checks if the given name is a valid identifier.
*
* If it is, this returns {@code true} and does nothing else.
diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
index 3c8a7039..0b054159 100644
--- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
@@ -35,6 +35,7 @@ import java.util.Set;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.core.AST.Kind;
+import lombok.core.handlers.HandlerUtil;
import lombok.core.AnnotationValues;
import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
@@ -271,7 +272,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
final boolean isEmpty = fields.isEmpty();
- /* final int PRIME = 31; */ {
+ /* final int PRIME = 277; */ {
/* Without fields, PRIME isn't used, and that would trigger a 'local variable not used' warning. */
if (!isEmpty || callSuper) {
LocalDeclaration primeDecl = new LocalDeclaration(PRIME, pS, pE);
@@ -280,7 +281,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
primeDecl.type = TypeReference.baseTypeReference(TypeIds.T_int, 0);
primeDecl.type.sourceStart = pS; primeDecl.type.sourceEnd = pE;
setGeneratedBy(primeDecl.type, source);
- primeDecl.initialization = makeIntLiteral("31".toCharArray(), source);
+ primeDecl.initialization = makeIntLiteral(String.valueOf(HandlerUtil.PRIME_FOR_HASHCODE).toCharArray(), source);
statements.add(primeDecl);
}
}
@@ -312,12 +313,12 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
Expression fieldAccessor = createFieldAccessor(field, fieldAccess, source);
if (fType.dimensions() == 0 && token != null) {
if (Arrays.equals(TypeConstants.BOOLEAN, token)) {
- /* booleanField ? 1231 : 1237 */
- IntLiteral int1231 = makeIntLiteral("1231".toCharArray(), source);
- IntLiteral int1237 = makeIntLiteral("1237".toCharArray(), source);
- ConditionalExpression int1231or1237 = new ConditionalExpression(fieldAccessor, int1231, int1237);
- setGeneratedBy(int1231or1237, source);
- statements.add(createResultCalculation(source, int1231or1237));
+ /* booleanField ? 2591 : 2609 */
+ IntLiteral intFalse = makeIntLiteral(String.valueOf(HandlerUtil.PRIME_FOR_FALSE).toCharArray(), source);
+ IntLiteral intTrue = makeIntLiteral(String.valueOf(HandlerUtil.PRIME_FOR_TRUE).toCharArray(), source);
+ ConditionalExpression intForBool = new ConditionalExpression(fieldAccessor, intFalse, intTrue);
+ setGeneratedBy(intForBool, source);
+ statements.add(createResultCalculation(source, intForBool));
} else if (Arrays.equals(TypeConstants.LONG, token)) {
statements.add(createLocalDeclaration(source, dollarFieldName, TypeReference.baseTypeReference(TypeIds.T_long, 0), fieldAccessor));
SingleNameReference copy1 = new SingleNameReference(dollarFieldName, p);
diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
index f3641f7f..3f72f8a1 100644
--- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
@@ -31,6 +31,7 @@ import java.util.Collections;
import lombok.EqualsAndHashCode;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
+import lombok.core.handlers.HandlerUtil;
import lombok.javac.Javac;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
@@ -230,9 +231,9 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
Name resultName = typeNode.toName(RESULT_NAME);
long finalFlag = JavacHandlerUtil.addFinalIfNeeded(0L, typeNode.getContext());
- /* final int PRIME = 31; */ {
+ /* final int PRIME = 277; */ {
if (!fields.isEmpty() || callSuper) {
- statements.append(maker.VarDef(maker.Modifiers(finalFlag), primeName, maker.TypeIdent(CTC_INT), maker.Literal(31)));
+ statements.append(maker.VarDef(maker.Modifiers(finalFlag), primeName, maker.TypeIdent(CTC_INT), maker.Literal(HandlerUtil.PRIME_FOR_HASHCODE)));
}
}
@@ -254,8 +255,9 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
if (fType instanceof JCPrimitiveTypeTree) {
switch (((JCPrimitiveTypeTree)fType).getPrimitiveTypeKind()) {
case BOOLEAN:
- /* this.fieldName ? 1231 : 1237 */
- statements.append(createResultCalculation(typeNode, maker.Conditional(fieldAccessor, maker.Literal(1231), maker.Literal(1237))));
+ /* this.fieldName ? 2591 : 2609 */
+ statements.append(createResultCalculation(typeNode, maker.Conditional(fieldAccessor,
+ maker.Literal(HandlerUtil.PRIME_FOR_FALSE), maker.Literal(HandlerUtil.PRIME_FOR_TRUE))));
break;
case LONG: {
Name dollarFieldName = dollar.append(((JCVariableDecl)fieldNode.get()).name);
diff --git a/test/transform/resource/after-delombok/Accessors.java b/test/transform/resource/after-delombok/Accessors.java
index 28ffc531..33f31825 100644
--- a/test/transform/resource/after-delombok/Accessors.java
+++ b/test/transform/resource/after-delombok/Accessors.java
@@ -84,7 +84,7 @@ class AccessorsPrefix3 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
final java.lang.Object $fName = this.getName();
result = result * PRIME + ($fName == null ? 0 : $fName.hashCode());
diff --git a/test/transform/resource/after-delombok/DataExtended.java b/test/transform/resource/after-delombok/DataExtended.java
index d580b885..76967bdc 100644
--- a/test/transform/resource/after-delombok/DataExtended.java
+++ b/test/transform/resource/after-delombok/DataExtended.java
@@ -28,7 +28,7 @@ class DataExtended {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getX();
return result;
diff --git a/test/transform/resource/after-delombok/DataIgnore.java b/test/transform/resource/after-delombok/DataIgnore.java
index b74b6a8f..caf97974 100644
--- a/test/transform/resource/after-delombok/DataIgnore.java
+++ b/test/transform/resource/after-delombok/DataIgnore.java
@@ -27,7 +27,7 @@ class DataIgnore {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getX();
return result;
diff --git a/test/transform/resource/after-delombok/DataOnLocalClass.java b/test/transform/resource/after-delombok/DataOnLocalClass.java
index abe2757b..fae0e4a5 100644
--- a/test/transform/resource/after-delombok/DataOnLocalClass.java
+++ b/test/transform/resource/after-delombok/DataOnLocalClass.java
@@ -39,7 +39,7 @@ class DataOnLocalClass1 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getX();
final java.lang.Object $name = this.getName();
@@ -99,7 +99,7 @@ class DataOnLocalClass2 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
final java.lang.Object $name = this.getName();
result = result * PRIME + ($name == null ? 0 : $name.hashCode());
@@ -136,7 +136,7 @@ class DataOnLocalClass2 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getX();
return result;
diff --git a/test/transform/resource/after-delombok/DataPlain.java b/test/transform/resource/after-delombok/DataPlain.java
index a8cb37af..99df699d 100644
--- a/test/transform/resource/after-delombok/DataPlain.java
+++ b/test/transform/resource/after-delombok/DataPlain.java
@@ -38,7 +38,7 @@ class Data1 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getX();
final java.lang.Object $name = this.getName();
@@ -91,7 +91,7 @@ class Data2 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getX();
final java.lang.Object $name = this.getName();
@@ -139,7 +139,7 @@ final class Data3 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getX();
final java.lang.Object $name = this.getName();
@@ -187,7 +187,7 @@ final class Data4 extends java.util.Timer {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + super.hashCode();
result = result * PRIME + this.getX();
diff --git a/test/transform/resource/after-delombok/DataWithGetter.java b/test/transform/resource/after-delombok/DataWithGetter.java
index 95a4bcbc..0aed0e12 100644
--- a/test/transform/resource/after-delombok/DataWithGetter.java
+++ b/test/transform/resource/after-delombok/DataWithGetter.java
@@ -36,7 +36,7 @@ class DataWithGetter {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getX();
result = result * PRIME + this.getY();
diff --git a/test/transform/resource/after-delombok/DataWithGetterNone.java b/test/transform/resource/after-delombok/DataWithGetterNone.java
index 2dea5e49..8b5ecc01 100644
--- a/test/transform/resource/after-delombok/DataWithGetterNone.java
+++ b/test/transform/resource/after-delombok/DataWithGetterNone.java
@@ -36,7 +36,7 @@ class DataWithGetterNone {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.x;
result = result * PRIME + this.y;
diff --git a/test/transform/resource/after-delombok/EqualsAndHashCode.java b/test/transform/resource/after-delombok/EqualsAndHashCode.java
index 8f84fb22..73256edb 100644
--- a/test/transform/resource/after-delombok/EqualsAndHashCode.java
+++ b/test/transform/resource/after-delombok/EqualsAndHashCode.java
@@ -29,7 +29,7 @@ class EqualsAndHashCode {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.x;
result = result * PRIME + java.util.Arrays.hashCode(this.y);
@@ -61,7 +61,7 @@ final class EqualsAndHashCode2 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.x;
final long $y = this.y;
@@ -111,7 +111,7 @@ class EqualsAndHashCode4 extends EqualsAndHashCode {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + super.hashCode();
return result;
diff --git a/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java b/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java
index 0a6b1e7f..e1bdc7f7 100644
--- a/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java
+++ b/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java
@@ -69,7 +69,7 @@ class EqualsAndHashCodeWithNoExistingMethods {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.x;
return result;
diff --git a/test/transform/resource/after-delombok/GetterLazyBoolean.java b/test/transform/resource/after-delombok/GetterLazyBoolean.java
index 08d32013..21b153c9 100644
--- a/test/transform/resource/after-delombok/GetterLazyBoolean.java
+++ b/test/transform/resource/after-delombok/GetterLazyBoolean.java
@@ -21,9 +21,9 @@ class GetterLazyBoolean {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
- result = result * PRIME + (this.isBooleanValue() ? 1231 : 1237);
+ result = result * PRIME + (this.isBooleanValue() ? 2591 : 2609);
return result;
}
@java.lang.Override
diff --git a/test/transform/resource/after-delombok/GetterLazyEahcToString.java b/test/transform/resource/after-delombok/GetterLazyEahcToString.java
index 1358e536..29e2f51c 100644
--- a/test/transform/resource/after-delombok/GetterLazyEahcToString.java
+++ b/test/transform/resource/after-delombok/GetterLazyEahcToString.java
@@ -27,7 +27,7 @@ class GetterLazyEahcToString {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
final java.lang.Object $value = this.getValue();
result = result * PRIME + ($value == null ? 0 : $value.hashCode());
diff --git a/test/transform/resource/after-delombok/GetterSetterJavadoc.java b/test/transform/resource/after-delombok/GetterSetterJavadoc.java
index af9cbb5e..5b12a395 100644
--- a/test/transform/resource/after-delombok/GetterSetterJavadoc.java
+++ b/test/transform/resource/after-delombok/GetterSetterJavadoc.java
@@ -41,7 +41,7 @@ class GetterSetterJavadoc1 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getFieldName();
return result;
diff --git a/test/transform/resource/after-delombok/ValuePlain.java b/test/transform/resource/after-delombok/ValuePlain.java
index d1cfa3d7..af87d1ba 100644
--- a/test/transform/resource/after-delombok/ValuePlain.java
+++ b/test/transform/resource/after-delombok/ValuePlain.java
@@ -30,7 +30,7 @@ final class Value1 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getX();
final java.lang.Object $name = this.getName();
@@ -80,7 +80,7 @@ class Value2 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getX();
final java.lang.Object $name = this.getName();
@@ -123,7 +123,7 @@ final class Value3 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = result * PRIME + this.getX();
result = result * PRIME + this.getY();
diff --git a/test/transform/resource/after-ecj/Accessors.java b/test/transform/resource/after-ecj/Accessors.java
index 292db928..52a72d52 100644
--- a/test/transform/resource/after-ecj/Accessors.java
+++ b/test/transform/resource/after-ecj/Accessors.java
@@ -90,7 +90,7 @@ class AccessorsChain {
return (other instanceof AccessorsPrefix3);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
final java.lang.Object $fName = this.getName();
result = ((result * PRIME) + (($fName == null) ? 0 : $fName.hashCode()));
diff --git a/test/transform/resource/after-ecj/DataExtended.java b/test/transform/resource/after-ecj/DataExtended.java
index 1de635e3..35a7ca34 100644
--- a/test/transform/resource/after-ecj/DataExtended.java
+++ b/test/transform/resource/after-ecj/DataExtended.java
@@ -22,7 +22,7 @@
return (other instanceof DataExtended);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getX());
return result;
diff --git a/test/transform/resource/after-ecj/DataIgnore.java b/test/transform/resource/after-ecj/DataIgnore.java
index 7d99a20f..4a3c051b 100644
--- a/test/transform/resource/after-ecj/DataIgnore.java
+++ b/test/transform/resource/after-ecj/DataIgnore.java
@@ -20,7 +20,7 @@
return (other instanceof DataIgnore);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getX());
return result;
diff --git a/test/transform/resource/after-ecj/DataOnLocalClass.java b/test/transform/resource/after-ecj/DataOnLocalClass.java
index 2f8dcca1..4a247542 100644
--- a/test/transform/resource/after-ecj/DataOnLocalClass.java
+++ b/test/transform/resource/after-ecj/DataOnLocalClass.java
@@ -36,7 +36,7 @@ class DataOnLocalClass1 {
return (other instanceof Local);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getX());
final java.lang.Object $name = this.getName();
@@ -86,7 +86,7 @@ class DataOnLocalClass2 {
return (other instanceof Local.InnerLocal);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
final java.lang.Object $name = this.getName();
result = ((result * PRIME) + (($name == null) ? 0 : $name.hashCode()));
@@ -124,7 +124,7 @@ class DataOnLocalClass2 {
return (other instanceof Local);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getX());
return result;
diff --git a/test/transform/resource/after-ecj/DataPlain.java b/test/transform/resource/after-ecj/DataPlain.java
index 1b33070b..2105c6f2 100644
--- a/test/transform/resource/after-ecj/DataPlain.java
+++ b/test/transform/resource/after-ecj/DataPlain.java
@@ -31,7 +31,7 @@ import lombok.Data;
return (other instanceof Data1);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getX());
final java.lang.Object $name = this.getName();
@@ -78,7 +78,7 @@ import lombok.Data;
return (other instanceof Data2);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getX());
final java.lang.Object $name = this.getName();
@@ -120,7 +120,7 @@ final @Data class Data3 {
return true;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getX());
final java.lang.Object $name = this.getName();
@@ -167,7 +167,7 @@ final @Data @lombok.EqualsAndHashCode(callSuper = true) class Data4 extends java
return (other instanceof Data4);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + super.hashCode());
result = ((result * PRIME) + this.getX());
diff --git a/test/transform/resource/after-ecj/DataWithGetter.java b/test/transform/resource/after-ecj/DataWithGetter.java
index 9d3dfd3e..9676e851 100644
--- a/test/transform/resource/after-ecj/DataWithGetter.java
+++ b/test/transform/resource/after-ecj/DataWithGetter.java
@@ -30,7 +30,7 @@
return (other instanceof DataWithGetter);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getX());
result = ((result * PRIME) + this.getY());
diff --git a/test/transform/resource/after-ecj/DataWithGetterNone.java b/test/transform/resource/after-ecj/DataWithGetterNone.java
index b6b391c8..d5e190d8 100644
--- a/test/transform/resource/after-ecj/DataWithGetterNone.java
+++ b/test/transform/resource/after-ecj/DataWithGetterNone.java
@@ -30,7 +30,7 @@
return (other instanceof DataWithGetterNone);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.x);
result = ((result * PRIME) + this.y);
diff --git a/test/transform/resource/after-ecj/EqualsAndHashCode.java b/test/transform/resource/after-ecj/EqualsAndHashCode.java
index 33ef799d..492f9344 100644
--- a/test/transform/resource/after-ecj/EqualsAndHashCode.java
+++ b/test/transform/resource/after-ecj/EqualsAndHashCode.java
@@ -35,7 +35,7 @@
return (other instanceof EqualsAndHashCode);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.x);
result = ((result * PRIME) + java.util.Arrays.hashCode(this.y));
@@ -72,7 +72,7 @@ final @lombok.EqualsAndHashCode class EqualsAndHashCode2 {
return true;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.x);
final long $y = this.y;
@@ -125,7 +125,7 @@ final @lombok.EqualsAndHashCode(callSuper = false) class EqualsAndHashCode3 exte
return (other instanceof EqualsAndHashCode4);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + super.hashCode());
return result;
diff --git a/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java b/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java
index cdd771a4..83878675 100644
--- a/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java
+++ b/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java
@@ -57,7 +57,7 @@ import static lombok.AccessLevel.NONE;
return (other instanceof EqualsAndHashCodeWithNoExistingMethods);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.x);
return result;
diff --git a/test/transform/resource/after-ecj/GetterLazyBoolean.java b/test/transform/resource/after-ecj/GetterLazyBoolean.java
index a51b164f..5b64c3b0 100644
--- a/test/transform/resource/after-ecj/GetterLazyBoolean.java
+++ b/test/transform/resource/after-ecj/GetterLazyBoolean.java
@@ -57,9 +57,9 @@
return (other instanceof GetterLazyBoolean);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
- result = ((result * PRIME) + (this.isBooleanValue() ? 1231 : 1237));
+ result = ((result * PRIME) + (this.isBooleanValue() ? 2591 : 2609));
return result;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
diff --git a/test/transform/resource/after-ecj/GetterLazyEahcToString.java b/test/transform/resource/after-ecj/GetterLazyEahcToString.java
index db2d4fcf..d8a90350 100644
--- a/test/transform/resource/after-ecj/GetterLazyEahcToString.java
+++ b/test/transform/resource/after-ecj/GetterLazyEahcToString.java
@@ -46,7 +46,7 @@
return (other instanceof GetterLazyEahcToString);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
final java.lang.Object $value = this.getValue();
result = ((result * PRIME) + (($value == null) ? 0 : $value.hashCode()));
diff --git a/test/transform/resource/after-ecj/GetterSetterJavadoc.java b/test/transform/resource/after-ecj/GetterSetterJavadoc.java
index 73f26180..10d9a0be 100644
--- a/test/transform/resource/after-ecj/GetterSetterJavadoc.java
+++ b/test/transform/resource/after-ecj/GetterSetterJavadoc.java
@@ -22,7 +22,7 @@
return (other instanceof GetterSetterJavadoc1);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getFieldName());
return result;
diff --git a/test/transform/resource/after-ecj/ValuePlain.java b/test/transform/resource/after-ecj/ValuePlain.java
index d095913f..a23944de 100644
--- a/test/transform/resource/after-ecj/ValuePlain.java
+++ b/test/transform/resource/after-ecj/ValuePlain.java
@@ -23,7 +23,7 @@ final @lombok.Value class Value1 {
return true;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getX());
final java.lang.Object $name = this.getName();
@@ -68,7 +68,7 @@ final @lombok.Value class Value1 {
return (other instanceof Value2);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getX());
final java.lang.Object $name = this.getName();
@@ -106,7 +106,7 @@ final @Value class Value3 {
return true;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = ((result * PRIME) + this.getX());
result = ((result * PRIME) + this.getY());
diff --git a/usage_examples/DataExample_post.jpage b/usage_examples/DataExample_post.jpage
index 3dc675e9..896839de 100644
--- a/usage_examples/DataExample_post.jpage
+++ b/usage_examples/DataExample_post.jpage
@@ -55,7 +55,7 @@ public class DataExample {
}
@Override public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
final long temp1 = Double.doubleToLongBits(this.getScore());
result = (result*PRIME) + (this.getName() == null ? 0 : this.getName().hashCode());
@@ -101,7 +101,7 @@ public class DataExample {
}
@Override public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = (result*PRIME) + (this.getName() == null ? 0 : this.getName().hashCode());
result = (result*PRIME) + (this.getValue() == null ? 0 : this.getValue().hashCode());
diff --git a/usage_examples/EqualsAndHashCodeExample_post.jpage b/usage_examples/EqualsAndHashCodeExample_post.jpage
index 4a90e7dc..57191f55 100644
--- a/usage_examples/EqualsAndHashCodeExample_post.jpage
+++ b/usage_examples/EqualsAndHashCodeExample_post.jpage
@@ -24,7 +24,7 @@ public class EqualsAndHashCodeExample {
}
@Override public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
final long temp1 = Double.doubleToLongBits(this.score);
result = (result*PRIME) + (this.name == null ? 0 : this.name.hashCode());
@@ -57,7 +57,7 @@ public class EqualsAndHashCodeExample {
}
@Override public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
result = (result*PRIME) + super.hashCode();
result = (result*PRIME) + this.width;
diff --git a/usage_examples/ValueExample_post.jpage b/usage_examples/ValueExample_post.jpage
index ac9b64d1..c5971262 100644
--- a/usage_examples/ValueExample_post.jpage
+++ b/usage_examples/ValueExample_post.jpage
@@ -46,7 +46,7 @@ public final class ValueExample {
@java.lang.Override
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 0 : $name.hashCode());
@@ -103,7 +103,7 @@ public final class ValueExample {
@java.lang.Override
public int hashCode() {
- final int PRIME = 31;
+ final int PRIME = 277;
int result = 1;
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 0 : $name.hashCode());