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

Comparing jsr166/src/jsr166e/Striped64.java (file contents):
Revision 1.6 by jsr166, Sat Oct 15 17:46:08 2011 UTC vs.
Revision 1.7 by jsr166, Wed Jan 9 02:51:37 2013 UTC

# Line 319 | Line 319 | abstract class Striped64 extends Number
319      private static sun.misc.Unsafe getUnsafe() {
320          try {
321              return sun.misc.Unsafe.getUnsafe();
322 <        } catch (SecurityException se) {
323 <            try {
324 <                return java.security.AccessController.doPrivileged
325 <                    (new java.security
326 <                     .PrivilegedExceptionAction<sun.misc.Unsafe>() {
327 <                        public sun.misc.Unsafe run() throws Exception {
328 <                            java.lang.reflect.Field f = sun.misc
329 <                                .Unsafe.class.getDeclaredField("theUnsafe");
330 <                            f.setAccessible(true);
331 <                            return (sun.misc.Unsafe) f.get(null);
332 <                        }});
333 <            } catch (java.security.PrivilegedActionException e) {
334 <                throw new RuntimeException("Could not initialize intrinsics",
335 <                                           e.getCause());
336 <            }
322 >        } catch (SecurityException tryReflectionInstead) {}
323 >        try {
324 >            return java.security.AccessController.doPrivileged
325 >            (new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
326 >                public sun.misc.Unsafe run() throws Exception {
327 >                    Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
328 >                    for (java.lang.reflect.Field f : k.getDeclaredFields()) {
329 >                        f.setAccessible(true);
330 >                        Object x = f.get(null);
331 >                        if (k.isInstance(x))
332 >                            return k.cast(x);
333 >                    }
334 >                    throw new NoSuchFieldError("the Unsafe");
335 >                }});
336 >        } catch (java.security.PrivilegedActionException e) {
337 >            throw new RuntimeException("Could not initialize intrinsics",
338 >                                       e.getCause());
339          }
340      }
339
341   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines