Incorrect line number in stack trace
Neal Gafter
neal at gafter.com
Mon Jun 16 08:27:28 PDT 2008
Mark-
Thanks for the report! I'll look into this after I've pushed the initial
prototype to the openjdk project.
Regards,
Neal
On Mon, Jun 16, 2008 at 5:42 AM, Mark Mahieu <mark at twistedbanana.demon.co.uk>
wrote:
> There appears to be some interaction between closures and for-each loops
> which can cause incorrect line numbers in stack traces.
>
> A couple of examples:
>
>
> public class StackTraceWrongLine1 {
>
> public static void main(String[] args) {
>
> // Stack trace indicates that the NPE occurs here:
> String[] items = null;
>
> // Comment out this line, and the stack trace is fine
> {==> void} notInvoked = {==> items = args; };
>
> for (String item : items) { }
> }
> }
>
>
> Exception in thread "main" java.lang.NullPointerException
> at StackTraceWrongLine1.main(StackTraceWrongLine1.java:6)
>
>
> - - - - - - - -
>
>
> public class StackTraceWrongLine2 {
>
> public static void main(String[] args) {
>
> // Stack trace indicates that items.iterator() is called
> here:
> Iterable<String> items = {=> throw new RuntimeException();
> };
>
> for (String item : items) { }
> }
> }
>
>
> Exception in thread "main" java.lang.RuntimeException
> at StackTraceWrongLine2$2.+invoke(StackTraceWrongLine2.java:6)
> at StackTraceWrongLine2$2.iterator(StackTraceWrongLine2.java:6)
> at StackTraceWrongLine2.main(StackTraceWrongLine2.java:6)
>
>
>
> Regards,
>
> Mark
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20080616/113678cb/attachment.html
More information about the closures-dev
mailing list