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

Comparing jsr166/src/jsr166y/ForkJoinTask.java (file contents):
Revision 1.98 by dl, Tue Jan 1 15:10:39 2013 UTC vs.
Revision 1.99 by jsr166, Wed Jan 9 02:51:37 2013 UTC

# Line 1485 | Line 1485 | public abstract class ForkJoinTask<V> im
1485      private static sun.misc.Unsafe getUnsafe() {
1486          try {
1487              return sun.misc.Unsafe.getUnsafe();
1488 <        } catch (SecurityException se) {
1489 <            try {
1490 <                return java.security.AccessController.doPrivileged
1491 <                    (new java.security
1492 <                     .PrivilegedExceptionAction<sun.misc.Unsafe>() {
1493 <                        public sun.misc.Unsafe run() throws Exception {
1494 <                            java.lang.reflect.Field f = sun.misc
1495 <                                .Unsafe.class.getDeclaredField("theUnsafe");
1496 <                            f.setAccessible(true);
1497 <                            return (sun.misc.Unsafe) f.get(null);
1498 <                        }});
1499 <            } catch (java.security.PrivilegedActionException e) {
1500 <                throw new RuntimeException("Could not initialize intrinsics",
1501 <                                           e.getCause());
1502 <            }
1488 >        } catch (SecurityException tryReflectionInstead) {}
1489 >        try {
1490 >            return java.security.AccessController.doPrivileged
1491 >            (new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
1492 >                public sun.misc.Unsafe run() throws Exception {
1493 >                    Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
1494 >                    for (java.lang.reflect.Field f : k.getDeclaredFields()) {
1495 >                        f.setAccessible(true);
1496 >                        Object x = f.get(null);
1497 >                        if (k.isInstance(x))
1498 >                            return k.cast(x);
1499 >                    }
1500 >                    throw new NoSuchFieldError("the Unsafe");
1501 >                }});
1502 >        } catch (java.security.PrivilegedActionException e) {
1503 >            throw new RuntimeException("Could not initialize intrinsics",
1504 >                                       e.getCause());
1505          }
1506      }
1505
1507   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines