--- jsr166/src/jsr166y/CountedCompleter.java 2012/12/15 21:26:06 1.28 +++ jsr166/src/jsr166y/CountedCompleter.java 2013/07/27 19:53:27 1.32 @@ -431,7 +431,7 @@ public abstract class CountedCompleter caller) { } @@ -449,9 +449,9 @@ public abstract class CountedCompleter caller) { return true; @@ -680,7 +680,7 @@ public abstract class CountedCompleter() { - public sun.misc.Unsafe run() throws Exception { - java.lang.reflect.Field f = sun.misc - .Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - return (sun.misc.Unsafe) f.get(null); - }}); - } catch (java.security.PrivilegedActionException e) { - throw new RuntimeException("Could not initialize intrinsics", - e.getCause()); - } + } catch (SecurityException tryReflectionInstead) {} + try { + return java.security.AccessController.doPrivileged + (new java.security.PrivilegedExceptionAction() { + public sun.misc.Unsafe run() throws Exception { + Class k = sun.misc.Unsafe.class; + for (java.lang.reflect.Field f : k.getDeclaredFields()) { + f.setAccessible(true); + Object x = f.get(null); + if (k.isInstance(x)) + return k.cast(x); + } + throw new NoSuchFieldError("the Unsafe"); + }}); + } catch (java.security.PrivilegedActionException e) { + throw new RuntimeException("Could not initialize intrinsics", + e.getCause()); } } }