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

Comparing jsr166/src/jsr166y/ForkJoinPool.java (file contents):
Revision 1.172 by jsr166, Fri Jan 4 18:52:18 2013 UTC vs.
Revision 1.173 by jsr166, Wed Jan 9 02:51:37 2013 UTC

# Line 3410 | Line 3410 | public class ForkJoinPool extends Abstra
3410      private static sun.misc.Unsafe getUnsafe() {
3411          try {
3412              return sun.misc.Unsafe.getUnsafe();
3413 <        } catch (SecurityException se) {
3414 <            try {
3415 <                return java.security.AccessController.doPrivileged
3416 <                    (new java.security
3417 <                     .PrivilegedExceptionAction<sun.misc.Unsafe>() {
3418 <                        public sun.misc.Unsafe run() throws Exception {
3419 <                            java.lang.reflect.Field f = sun.misc
3420 <                                .Unsafe.class.getDeclaredField("theUnsafe");
3421 <                            f.setAccessible(true);
3422 <                            return (sun.misc.Unsafe) f.get(null);
3423 <                        }});
3424 <            } catch (java.security.PrivilegedActionException e) {
3425 <                throw new RuntimeException("Could not initialize intrinsics",
3426 <                                           e.getCause());
3427 <            }
3413 >        } catch (SecurityException tryReflectionInstead) {}
3414 >        try {
3415 >            return java.security.AccessController.doPrivileged
3416 >            (new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
3417 >                public sun.misc.Unsafe run() throws Exception {
3418 >                    Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
3419 >                    for (java.lang.reflect.Field f : k.getDeclaredFields()) {
3420 >                        f.setAccessible(true);
3421 >                        Object x = f.get(null);
3422 >                        if (k.isInstance(x))
3423 >                            return k.cast(x);
3424 >                    }
3425 >                    throw new NoSuchFieldError("the Unsafe");
3426 >                }});
3427 >        } catch (java.security.PrivilegedActionException e) {
3428 >            throw new RuntimeException("Could not initialize intrinsics",
3429 >                                       e.getCause());
3430          }
3431      }
3430
3432   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines