From a40a86ad532881acd311200a665b5f55790c55cc Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 9 Jan 2014 21:00:44 +0100 Subject: [#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. --- src/core/lombok/core/handlers/HandlerUtil.java | 6 +++++- .../eclipse/handlers/HandleEqualsAndHashCode.java | 17 +++++++++-------- .../lombok/javac/handlers/HandleEqualsAndHashCode.java | 10 ++++++---- 3 files changed, 20 insertions(+), 13 deletions(-) (limited to 'src') 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