--- jsr166/src/jsr166e/ForkJoinTask.java 2012/12/19 00:02:52 1.7
+++ jsr166/src/jsr166e/ForkJoinTask.java 2013/02/05 17:09:54 1.12
@@ -134,7 +134,8 @@ import java.lang.reflect.Constructor;
* (DAG). Otherwise, executions may encounter a form of deadlock as
* tasks cyclically wait for each other. However, this framework
* supports other methods and techniques (for example the use of
- * {@link Phaser}, {@link #helpQuiesce}, and {@link #complete}) that
+ * {@link java.util.concurrent.Phaser}, {@link #helpQuiesce}, and
+ * {@link #complete}) that
* may be of use in constructing custom subclasses for problems that
* are not statically structured as DAGs. To support such usages a
* ForkJoinTask may be atomically tagged with a {@code short}
@@ -435,7 +436,7 @@ public abstract class ForkJoinTask im
}
/**
- * Records exception and possibly propagates
+ * Records exception and possibly propagates.
*
* @return status on exit
*/
@@ -468,7 +469,7 @@ public abstract class ForkJoinTask im
}
/**
- * Removes exception node and clears status
+ * Removes exception node and clears status.
*/
private void clearExceptionalCompletion() {
int h = System.identityHashCode(this);
@@ -606,7 +607,7 @@ public abstract class ForkJoinTask im
throw (Error)ex;
if (ex instanceof RuntimeException)
throw (RuntimeException)ex;
- throw uncheckedThrowable(ex, RuntimeException.class);
+ ForkJoinTask.uncheckedThrow(ex);
}
}
@@ -616,8 +617,9 @@ public abstract class ForkJoinTask im
* unchecked exceptions
*/
@SuppressWarnings("unchecked") static
- T uncheckedThrowable(final Throwable t, final Class c) {
- return (T)t; // rely on vacuous cast
+ void uncheckedThrow(Throwable t) throws T {
+ if (t != null)
+ throw (T)t; // rely on vacuous cast
}
/**
@@ -652,7 +654,7 @@ public abstract class ForkJoinTask im
if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
((ForkJoinWorkerThread)t).workQueue.push(this);
else
- ForkJoinPool.commonPool.externalPush(this);
+ ForkJoinPool.common.externalPush(this);
return this;
}
@@ -1076,7 +1078,7 @@ public abstract class ForkJoinTask im
wt.pool.helpQuiescePool(wt.workQueue);
}
else
- ForkJoinPool.externalHelpQuiescePool();
+ ForkJoinPool.quiesceCommonPool();
}
/**
@@ -1484,22 +1486,23 @@ public abstract class ForkJoinTask im
private static sun.misc.Unsafe getUnsafe() {
try {
return sun.misc.Unsafe.getUnsafe();
- } catch (SecurityException se) {
- try {
- return java.security.AccessController.doPrivileged
- (new java.security
- .PrivilegedExceptionAction() {
- 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());
}
}
-
}