Mark-<br><br>Thanks for the report! I'll look into this after I've pushed the initial prototype to the openjdk project.<br><br>Regards,<br>Neal<br><br><div class="gmail_quote">On Mon, Jun 16, 2008 at 5:42 AM, Mark Mahieu <<a href="mailto:mark@twistedbanana.demon.co.uk">mark@twistedbanana.demon.co.uk</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">There appears to be some interaction between closures and for-each loops which can cause incorrect line numbers in stack traces.<br>
<br>
A couple of examples:<br>
<br>
<br>
public class StackTraceWrongLine1 {<br>
<br>
public static void main(String[] args) {<br>
<br>
// Stack trace indicates that the NPE occurs here:<br>
String[] items = null;<br>
<br>
// Comment out this line, and the stack trace is fine<br>
{==> void} notInvoked = {==> items = args; };<br>
<br>
for (String item : items) { }<br>
}<br>
}<br>
<br>
<br>
Exception in thread "main" java.lang.NullPointerException<br>
at StackTraceWrongLine1.main(StackTraceWrongLine1.java:6)<br>
<br>
<br>
- - - - - - - -<br>
<br>
<br>
public class StackTraceWrongLine2 {<br>
<br>
public static void main(String[] args) {<br>
<br>
// Stack trace indicates that items.iterator() is called here:<br>
Iterable<String> items = {=> throw new RuntimeException(); };<br>
<br>
for (String item : items) { }<br>
}<br>
}<br>
<br>
<br>
Exception in thread "main" java.lang.RuntimeException<br>
at StackTraceWrongLine2$2.+invoke(StackTraceWrongLine2.java:6)<br>
at StackTraceWrongLine2$2.iterator(StackTraceWrongLine2.java:6)<br>
at StackTraceWrongLine2.main(StackTraceWrongLine2.java:6)<br>
<br>
<br>
<br>
Regards,<br><font color="#888888">
<br>
Mark<br>
<br>
</font></blockquote></div><br>