All of the examples I've seen where you could get into this kind of "trouble" involve making locally obvious errors. The exception points you precisely to where you made the mistake, too. In this case the temp() method clearly constructs a closure that should not escape its scope (it has a return in it) yet is assigned to a static variable.<br>
<br><div class="gmail_quote">On Sat, Nov 15, 2008 at 8:26 PM, Vladimir Kirichenko <span dir="ltr"><<a href="mailto:vladimir.kirichenko@gmail.com">vladimir.kirichenko@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
More accurate problematic example:<br>
<br>
public class Test {<br>
<br>
static {int ==> int} temp;<br>
<br>
static void term() {<br>
{int==>int} t = {int i ==> if (i > 5) return; i};<br>
temp = t;<br>
<br>
}<br>
<br>
static int m(int i, {int ==> int} f) {<br>
int y = f.invoke(i + 5);<br>
return y;<br>
}<br>
<br>
static int caller(int i) {<br>
return m(i,temp);<br>
}<br>
public static void main(String... args) {<br>
term();<br>
int x = caller(5);<br>
System.out.println(x);<br>
}<br>
}<br>
<br>
Exception in thread "main" java.lang.UnmatchedTransfer: late transfer<br>
at java.lang.Jump.transfer(Jump.java:48)<br>
at test.Test$3.+invoke(Test.java:12)<br>
at test.Test$3.invoke(Test.java:12)<br>
at test.Test.m(Test.java:18)<br>
at test.Test.caller(Test.java:23)<br>
at test.Test.main(Test.java:29)<br>
Caused by: test.Test$2<br>
<br>
And it's not the bug - code like this could appear in different cases,<br>
it just shows what unrestricted closures passing could raise.<br>
<br>
<br>
-- <br>
Best Regards,<br><font color="#888888">
Vladimir Kirichenko<br>
</font><br>-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v2.0.4-svn0 (GNU/Linux)<br>
Comment: Using GnuPG with SUSE - <a href="http://enigmail.mozdev.org" target="_blank">http://enigmail.mozdev.org</a><br>
<br>
iD8DBQFJH5KD2HRuYYrY4NQRAlR8AJ0dClhBvckn4NMiF14oBjTIijZ6BACdFgF3<br>
Zd8fWLKRU1XGF0ob9vEmTqo=<br>
=uZP4<br>
-----END PGP SIGNATURE-----<br>
<br>
<br></blockquote></div><br>