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

Comparing jsr166/src/jsr166y/Phaser.java (file contents):
Revision 1.78 by jsr166, Sun Nov 18 18:03:10 2012 UTC vs.
Revision 1.79 by jsr166, Wed Jan 9 02:51:37 2013 UTC

# Line 1142 | Line 1142 | public class Phaser {
1142      private static sun.misc.Unsafe getUnsafe() {
1143          try {
1144              return sun.misc.Unsafe.getUnsafe();
1145 <        } catch (SecurityException se) {
1146 <            try {
1147 <                return java.security.AccessController.doPrivileged
1148 <                    (new java.security
1149 <                     .PrivilegedExceptionAction<sun.misc.Unsafe>() {
1150 <                        public sun.misc.Unsafe run() throws Exception {
1151 <                            java.lang.reflect.Field f = sun.misc
1152 <                                .Unsafe.class.getDeclaredField("theUnsafe");
1153 <                            f.setAccessible(true);
1154 <                            return (sun.misc.Unsafe) f.get(null);
1155 <                        }});
1156 <            } catch (java.security.PrivilegedActionException e) {
1157 <                throw new RuntimeException("Could not initialize intrinsics",
1158 <                                           e.getCause());
1159 <            }
1145 >        } catch (SecurityException tryReflectionInstead) {}
1146 >        try {
1147 >            return java.security.AccessController.doPrivileged
1148 >            (new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
1149 >                public sun.misc.Unsafe run() throws Exception {
1150 >                    Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
1151 >                    for (java.lang.reflect.Field f : k.getDeclaredFields()) {
1152 >                        f.setAccessible(true);
1153 >                        Object x = f.get(null);
1154 >                        if (k.isInstance(x))
1155 >                            return k.cast(x);
1156 >                    }
1157 >                    throw new NoSuchFieldError("the Unsafe");
1158 >                }});
1159 >        } catch (java.security.PrivilegedActionException e) {
1160 >            throw new RuntimeException("Could not initialize intrinsics",
1161 >                                       e.getCause());
1162          }
1163      }
1164   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines