Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2706 - Switching to a type system subversion instead of Unsafe.throwExc... #866

Merged
merged 1 commit into from Nov 14, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion akka-actor/src/main/java/akka/jsr166y/ForkJoinPool.java
Expand Up @@ -1372,7 +1372,7 @@ final void deregisterWorker(ForkJoinWorkerThread wt, Throwable ex) {
}

if (ex != null) // rethrow
U.throwException(ex);
rethrow(ex);
}


Expand Down Expand Up @@ -2856,4 +2856,15 @@ private static sun.misc.Unsafe getUnsafe() {
return Unsafe.instance;
}

final static void rethrow(final Throwable t) {
throwSoftUnchecked(t, RuntimeException.class);
}

@SuppressWarnings("unchecked")
private final static <T extends Throwable> void throwSoftUnchecked(
final Throwable t,
final Class<T> infer) throws T {
throw (T)t;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a nasty trick :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is definitely Dark Art.

}

}
6 changes: 3 additions & 3 deletions akka-actor/src/main/java/akka/jsr166y/ForkJoinTask.java
Expand Up @@ -592,7 +592,7 @@ private void reportException(int s) {
(s == EXCEPTIONAL) ? getThrowableException() :
null);
if (ex != null)
U.throwException(ex);
ForkJoinPool.rethrow(ex);
}

// public methods
Expand Down Expand Up @@ -730,7 +730,7 @@ else if (t.doJoin() < NORMAL)
}
}
if (ex != null)
U.throwException(ex);
ForkJoinPool.rethrow(ex);
}

/**
Expand Down Expand Up @@ -787,7 +787,7 @@ else if (t.doJoin() < NORMAL)
}
}
if (ex != null)
U.throwException(ex);
ForkJoinPool.rethrow(ex);
return tasks;
}

Expand Down