We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Getting a NullPointerException in a comment
Page Index Toggle Pages: 1
Getting a NullPointerException in a comment (Read 410 times)
Getting a NullPointerException in a comment
Feb 18th, 2010, 3:41pm
 
Got a NullPointerException today and it was right in the middle of a huge block comment.

Code:
Exception in thread "Animation Thread" java.lang.NullPointerException
at voronoi.intersect(voronoi.java:245)
at voronoi.frontInsert(voronoi.java:122)
at voronoi.runFortune(voronoi.java:75)


Line 245 is in the intersect() method, but that method's contents have been completely commented out.

I am an experienced programmer and this just has me completely stumped. I'm on the verge of insanity here. Shocked

What exactly does processing do to the code before you see the applet?
is it compiled or interpreted? is anything added to it that would make the line numbers in the errors unreliable?
Re: Getting a NullPointerException in a comment
Reply #1 - Feb 19th, 2010, 2:19am
 
Hard to tell without knowing the structure of your code (using .java files? several files/tabs?).

At least, I can explain what Processing does when compiling: it collects all the .pde files into one class named as the sketch. The .java files are compiled separately.
That means that line l of nth file will actually be line ll > l in final file. And you can add lines for import declarations, class declaration, the main(), etc.
The generated file is compiled with javac after processing (replacing 'color' with 'int' and so on).
When there is a compiler error, Processing attempts to map the reported line to the proper buffer and line in it.

The problem is that runtime errors are reported by Java against the final generated .java file.
Good news is that you can find back that file in the temp dir of your system. Or perhaps export to HTML, I think the .java file is outputted as well.
Page Index Toggle Pages: 1