ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166e/ConcurrentHashMapV8.java
(Generate patch)

Comparing jsr166/src/jsr166e/ConcurrentHashMapV8.java (file contents):
Revision 1.85 by jsr166, Wed Jan 2 07:43:49 2013 UTC vs.
Revision 1.89 by jsr166, Sat Jan 19 20:39:43 2013 UTC

# Line 567 | Line 567 | public class ConcurrentHashMapV8<K, V>
567      static final int SEED_INCREMENT = 0x61c88647;
568  
569      /**
570 <     * Per-thread counter hash codes. Shared across all instances
570 >     * Per-thread counter hash codes. Shared across all instances.
571       */
572      static final ThreadLocal<CounterHashCode> threadCounterHashCode =
573          new ThreadLocal<CounterHashCode>();
# Line 4577 | Line 4577 | public class ConcurrentHashMapV8<K, V>
4577      /**
4578       * Base class for views.
4579       */
4580 <    static abstract class CHMView<K, V> {
4580 >    abstract static class CHMView<K, V> {
4581          final ConcurrentHashMapV8<K, V> map;
4582          CHMView(ConcurrentHashMapV8<K, V> map)  { this.map = map; }
4583  
# Line 4593 | Line 4593 | public class ConcurrentHashMapV8<K, V>
4593          public final void clear()               { map.clear(); }
4594  
4595          // implementations below rely on concrete classes supplying these
4596 <        abstract public Iterator<?> iterator();
4597 <        abstract public boolean contains(Object o);
4598 <        abstract public boolean remove(Object o);
4596 >        public abstract Iterator<?> iterator();
4597 >        public abstract boolean contains(Object o);
4598 >        public abstract boolean remove(Object o);
4599  
4600          private static final String oomeMsg = "Required array size too large";
4601  
# Line 6804 | Line 6804 | public class ConcurrentHashMapV8<K, V>
6804      private static final int ASHIFT;
6805  
6806      static {
6807        int ss;
6807          try {
6808              U = getUnsafe();
6809              Class<?> k = ConcurrentHashMapV8.class;
# Line 6823 | Line 6822 | public class ConcurrentHashMapV8<K, V>
6822                  (ck.getDeclaredField("value"));
6823              Class<?> sc = Node[].class;
6824              ABASE = U.arrayBaseOffset(sc);
6825 <            ss = U.arrayIndexScale(sc);
6826 <            ASHIFT = 31 - Integer.numberOfLeadingZeros(ss);
6825 >            int scale = U.arrayIndexScale(sc);
6826 >            if ((scale & (scale - 1)) != 0)
6827 >                throw new Error("data type scale not a power of two");
6828 >            ASHIFT = 31 - Integer.numberOfLeadingZeros(scale);
6829          } catch (Exception e) {
6830              throw new Error(e);
6831          }
6831        if ((ss & (ss-1)) != 0)
6832            throw new Error("data type scale not a power of two");
6832      }
6833  
6834      /**
# Line 6842 | Line 6841 | public class ConcurrentHashMapV8<K, V>
6841      private static sun.misc.Unsafe getUnsafe() {
6842          try {
6843              return sun.misc.Unsafe.getUnsafe();
6844 <        } catch (SecurityException se) {
6845 <            try {
6846 <                return java.security.AccessController.doPrivileged
6847 <                    (new java.security
6848 <                     .PrivilegedExceptionAction<sun.misc.Unsafe>() {
6849 <                        public sun.misc.Unsafe run() throws Exception {
6850 <                            java.lang.reflect.Field f = sun.misc
6851 <                                .Unsafe.class.getDeclaredField("theUnsafe");
6852 <                            f.setAccessible(true);
6853 <                            return (sun.misc.Unsafe) f.get(null);
6854 <                        }});
6855 <            } catch (java.security.PrivilegedActionException e) {
6856 <                throw new RuntimeException("Could not initialize intrinsics",
6857 <                                           e.getCause());
6858 <            }
6844 >        } catch (SecurityException tryReflectionInstead) {}
6845 >        try {
6846 >            return java.security.AccessController.doPrivileged
6847 >            (new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
6848 >                public sun.misc.Unsafe run() throws Exception {
6849 >                    Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
6850 >                    for (java.lang.reflect.Field f : k.getDeclaredFields()) {
6851 >                        f.setAccessible(true);
6852 >                        Object x = f.get(null);
6853 >                        if (k.isInstance(x))
6854 >                            return k.cast(x);
6855 >                    }
6856 >                    throw new NoSuchFieldError("the Unsafe");
6857 >                }});
6858 >        } catch (java.security.PrivilegedActionException e) {
6859 >            throw new RuntimeException("Could not initialize intrinsics",
6860 >                                       e.getCause());
6861          }
6862      }
6863   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines