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.86 by jsr166, Sun Jan 6 20:05:51 2013 UTC vs.
Revision 1.87 by jsr166, Wed Jan 9 02:51:36 2013 UTC

# Line 6842 | Line 6842 | public class ConcurrentHashMapV8<K, V>
6842      private static sun.misc.Unsafe getUnsafe() {
6843          try {
6844              return sun.misc.Unsafe.getUnsafe();
6845 <        } catch (SecurityException se) {
6846 <            try {
6847 <                return java.security.AccessController.doPrivileged
6848 <                    (new java.security
6849 <                     .PrivilegedExceptionAction<sun.misc.Unsafe>() {
6850 <                        public sun.misc.Unsafe run() throws Exception {
6851 <                            java.lang.reflect.Field f = sun.misc
6852 <                                .Unsafe.class.getDeclaredField("theUnsafe");
6853 <                            f.setAccessible(true);
6854 <                            return (sun.misc.Unsafe) f.get(null);
6855 <                        }});
6856 <            } catch (java.security.PrivilegedActionException e) {
6857 <                throw new RuntimeException("Could not initialize intrinsics",
6858 <                                           e.getCause());
6859 <            }
6845 >        } catch (SecurityException tryReflectionInstead) {}
6846 >        try {
6847 >            return java.security.AccessController.doPrivileged
6848 >            (new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
6849 >                public sun.misc.Unsafe run() throws Exception {
6850 >                    Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
6851 >                    for (java.lang.reflect.Field f : k.getDeclaredFields()) {
6852 >                        f.setAccessible(true);
6853 >                        Object x = f.get(null);
6854 >                        if (k.isInstance(x))
6855 >                            return k.cast(x);
6856 >                    }
6857 >                    throw new NoSuchFieldError("the Unsafe");
6858 >                }});
6859 >        } catch (java.security.PrivilegedActionException e) {
6860 >            throw new RuntimeException("Could not initialize intrinsics",
6861 >                                       e.getCause());
6862          }
6863      }
6864   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines