Working snapshot.
authorgafter
Sat Jul 26 22:59:05 2008 -0700 (16 months ago)
changeset 406bce5c22022e1
parent 405cab2003d7915
child 4079c822849adfe
Working snapshot.
src/share/classes/java/lang/Jump.java
src/share/classes/java/lang/UnmatchedTransfer.java
--- a/src/share/classes/java/lang/Jump.java Sun Jul 13 20:47:48 2008 -0700
+++ b/src/share/classes/java/lang/Jump.java Sat Jul 26 22:59:05 2008 -0700
@@ -28,23 +28,25 @@ package java.lang;
/**
* Class used to implement transfers from within a lambda.
* This should only be thrown when the target of the transfer is on
- * the call stack of the current thread.
+ * the call stack of the current thread. Note: ideally, Jump would
+ * be placed in an exception hierarchy aside from Throwable, to help
+ * preserve transparency of transfers implemented using this
+ * mechanism.
*
* @author gafter
*/
-public class Jump extends RuntimeException {
+public abstract class Jump extends RuntimeException {
/**
* Returns the thread in which the transfer target is executing.
*/
- public Thread thread() {
- return Thread.currentThread();
- }
+ public abstract Thread thread();
/**
* Cause the transfer to occur.
*/
- public Nothing transfer() {
- throw this;
+ public RuntimeException transfer() {
+ return (Thread.currentThread() == thread())
+ ? this : new UnmatchedTransfer(this);
}
/**
--- a/src/share/classes/java/lang/UnmatchedTransfer.java Sun Jul 13 20:47:48 2008 -0700
+++ b/src/share/classes/java/lang/UnmatchedTransfer.java Sat Jul 26 22:59:05 2008 -0700
@@ -32,6 +32,7 @@ package java.lang;
* @author gafter
*/
public class UnmatchedTransfer extends RuntimeException {
+
/** The Jump that causes the control transfer. */
private final Jump jump;
@@ -48,7 +49,7 @@ public class UnmatchedTransfer extends R
/**
* Cause the transfer to occur.
*/
- public Nothing transfer() {
- return jump.transfer();
+ public RuntimeException transfer() {
+ return jump.transfer();
}
}