changeset 5103:f1e9d1264ce6

7178548: Hashtable alternative hashing threshold default ignored Summary: Due to a patch merge error a manifest constant (a number) was used rather than the symbolic constant ALTERNATE_HASHING_THRESHOLD_DEFAULT for the alternate hashing threshold. When CR#773918 was applied it had no effect because the symbolic constant was not referenced. Reviewed-by: dholmes, alanb
author mduigou
date Wed, 20 Jun 2012 14:38:04 -0700
parents 002ca3d97d19
children 2a08d45743f4
files src/share/classes/java/util/HashMap.java src/share/classes/java/util/Hashtable.java src/share/classes/java/util/WeakHashMap.java src/share/classes/java/util/concurrent/ConcurrentHashMap.java
diffstat 4 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/HashMap.java	Fri Jun 22 15:20:55 2012 +0400
+++ b/src/share/classes/java/util/HashMap.java	Wed Jun 20 14:38:04 2012 -0700
@@ -221,6 +221,7 @@
                         ? Integer.parseInt(altThreshold)
                         : ALTERNATE_HASHING_THRESHOLD_DEFAULT;
 
+                // disable alternative hashing if -1
                 if(threshold == -1) {
                     threshold = Integer.MAX_VALUE;
                 }
--- a/src/share/classes/java/util/Hashtable.java	Fri Jun 22 15:20:55 2012 +0400
+++ b/src/share/classes/java/util/Hashtable.java	Wed Jun 20 14:38:04 2012 -0700
@@ -171,7 +171,7 @@
      * This value may be overridden by defining the system property
      * {@code java.util.althashing.threshold}. A property value of {@code 1}
      * forces alternative hashing to be used at all times whereas
-     * {@code 2147483648 } ({@code Integer.MAX_VALUE}) value ensures that
+     * {@code -1 } value ensures that
      * alternative hashing is never used.
      */
     static final int ALTERNATE_HASHING_THRESHOLD_DEFAULT = 512;
@@ -195,8 +195,9 @@
             try {
                 threshold = (null != altThreshold)
                         ? Integer.parseInt(altThreshold)
-                        : 1;
+                        : ALTERNATE_HASHING_THRESHOLD_DEFAULT;
 
+                // disable alternative hashing if -1
                 if(threshold == -1) {
                     threshold = Integer.MAX_VALUE;
                 }
--- a/src/share/classes/java/util/WeakHashMap.java	Fri Jun 22 15:20:55 2012 +0400
+++ b/src/share/classes/java/util/WeakHashMap.java	Wed Jun 20 14:38:04 2012 -0700
@@ -218,6 +218,7 @@
                         ? Integer.parseInt(altThreshold)
                         : ALTERNATE_HASHING_THRESHOLD_DEFAULT;
 
+                // disable alternative hashing if -1
                 if(threshold == -1) {
                     threshold = Integer.MAX_VALUE;
                 }
@@ -356,7 +357,7 @@
         if (useAltHashing) {
             h = hashSeed;
             if (k instanceof String) {
-                return h ^ sun.misc.Hashing.stringHash32((String) k);
+                return sun.misc.Hashing.stringHash32((String) k);
             } else {
                 h ^= k.hashCode();
             }
--- a/src/share/classes/java/util/concurrent/ConcurrentHashMap.java	Fri Jun 22 15:20:55 2012 +0400
+++ b/src/share/classes/java/util/concurrent/ConcurrentHashMap.java	Wed Jun 20 14:38:04 2012 -0700
@@ -198,6 +198,7 @@
                         ? Integer.parseInt(altThreshold)
                         : 1;
 
+                // disable alternative hashing if -1
                 if(threshold == -1) {
                     threshold = Integer.MAX_VALUE;
                 }