Suggestions for tracking down a null pointer exception?

Following this simple good tutorial:

http://confluence.jetbrains.com/display/IntelliJIDEA/Custom+Language+Support

has mostly worked for me but I have deviated slightly away from simple properties to a trivial programming language. Unfortunately, I literally am stuck now. Icannot get simple structured view. I get a null pointer exception but the location is destroyed because I think it jumps between threads or something.

[   8560]  ERROR - plication.impl.ApplicationImpl - java.lang.NullPointerException
java.lang.RuntimeException: java.lang.NullPointerException
 at com.intellij.ide.util.treeView.AbstractTreeUi$57$1.run(AbstractTreeUi.java:3415)
 at com.intellij.ide.util.treeView.AbstractTreeBuilder$4.run(AbstractTreeBuilder.java:473)
 at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:947)
 at com.intellij.ide.util.treeView.AbstractTreeBuilder.runBackgroundLoading(AbstractTreeBuilder.java:470)
 at com.intellij.ide.util.treeView.AbstractTreeUi$57.run(AbstractTreeUi.java:3370)

...

The  AbstractTreeUi.java:3415 location is trapping the exception and re-throwing:

                throw new RuntimeException(t);

I can't imagine that destroying the trace normally (must be a thread hopping thing) but the trace is empty for t in the debugger. I'm 99% sure it has something to do with getting the children of a structured view tree element.  I think that the children list is coming back null inappropriately sometimes.  Despite breakpoints everywhere, no luck. I've spent many hours on this trying to step through the code and debug. Naturally this is almost impossible with the dozen threads are so going on. We have no idea where it's triggering the exception so I don't think anybody could debug this without complete expertise in the source code.

Now that I've moved out of my expertise in parsing perhaps I will get no further. No offense, but this has been unbelievably frustrating trying to create a simple plug-in.  Fortunately your source code is very good and so I can mostly answer my own questions using the debugger and reading source code. That said, I'm just about ready to throw away everything I've learned, which would be a pity because then there is no simple ANTLR integration into Intellij.  I don't think I have response so far to my last question about a suspicious thread error message.  I understand that people are busy at jetbrains but I think you could devote a little bit more resources to pay people to help with plug-in development; seems like it would be hurting your business not have more plug-ins.  If you guys think that having the ANTLR support for plug-ins is useful, can you allocate part of a human to help me out with these roadblocks? I have a lot more interesting projects to  work on and I'm just about at my threshold of pain.

Thanks,
Terence
5 comments

I feel your pain - sometimes developing plugins is an exercise in frustration. I have a few unanswered questions floating around here which have cost me a massive amount of time and hair-pulling too. I don't have a good solution for your problem unfortunately, but I do hope you persist - I think an ANTLR integration would be great, and when everything works in plugin development it's like magic.

Actually, one suggestion - if you can reproduce this easily, try setting an exception breakpoint for NPE, that should break when the exception actually occurs. Generally it's difficult to leave these breakpoints set for long since it's amazing how often these exceptions are thrown and caught inside frameworks, but if you can enable the exception and then reproduce the problem they're sometimes invaluable. Otherwise, do you have your code somewhere so that we can try to reproduce?

0

great advice, Colin! Didn't know you could trap those ;)  I'm shocked that jetbrains doesn't care enough about ANTLR integration to give me some extra attention here.  They really don't seem to care about plugin support in general. Curious behavior.

0

i should also point out that, despite requesting email notification, I just realized I only randomly get email from replies on this forum. yet more frustration!!! now i will go look for replies manually.

0

Dear Terence,

We do care in fact. Unfortunately sometimes it is hard to help without the ability to really reproduce the problem.
The AbstratTreeUi you mentioned is a very complicated piece of code we often have to debug ourselves (frustrations & aforementioned hair-pulling included).

Please always attach IDEA log files in full (Help/Show Log menu) along with exception trace snippets.

If logs/traces don't help we'll need plugin code and steps to reproduce in order to help proactively.
YouTrack tickets with optional jetbrains-team or idea-developers visibility can be used to privately share code instead of posting it on this forum.

Thank you for your work,

Greg

0

Hi Greg,  thanks for the reply. Yep, part of the frustration is that there is no way to trace a null pointer problem without the stack trace. Well, that is until Colin pointed out that I can trap the generation of exceptions. I had never needed that before in 18 yrs of java dev because of stack traces and so I was super excited to see that intellij was able to track those. that has led me to discover my presentation in the structure view is coming back null sometimes and it is not the list of children as I suspected. It's very strange that the trace gets destroyed. It must be some weird thread hopping thing.

I'll be releasing the plug-in stuff open source so there's no problem with private codesharing. Am happy to supply the code. So, I can use youtrack tickets for non-intellij bugs? I.e., to get help when difficult plug-in development problems? That would be great!

I'll start my structure view from scratch as I now have some bastard child of the properties example and a blog entry. It's extremely complicated to track AST, PSI, structure view elements, presentation elements and which ones need pointers to which. Yikes!  I'm sure a flexible tool like intellij it would be impossible without so many levels of indirection though.

Thanks for the response...I have something to chew on now that I've trapped the null pointer! I'm still having weird thread issues but that could be because a null pointer exception is forcing it down an invalid path.

Ter

0

Please sign in to leave a comment.