antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
17.21k stars 3.29k forks source link

NullPointerException in runtime: Parser.notifyErrorListeners() #746

Closed fmela closed 9 years ago

fmela commented 10 years ago
java.lang.NullPointerException: null
    at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:557) ~[antlr4-runtime-4.3.jar:4.3]
    at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:157) ~[antlr4-runtime-4.3.jar:4.3]

Looks to be happening here.

sharwell commented 10 years ago

This error occurs within a rarely used, largely undocumented portion of the runtime library (throwing non-standard RecognitionException exceptions and expecting the error handler to handle them). At least for now, you must call RecognitionException.setOffendingToken with a non-null Token instance prior to throwing the exception.

I'm open to suggestions for a long-term solution for this, but keep in mind removing the @NotNull annotation from the offendingToken argument to notifyErrorListeners would be a breaking change that we want to avoid if at all possible.

parrt commented 9 years ago

Hi. Not sure how offendingToken could ever be null. Does this happen for you still in 4.5? I'm closing as it's likely something altering normal error mechanism.

fmela commented 9 years ago

I no longer have access to the source code that triggered this, but maybe @benmccann could test with 4.5 and comment.

parrt commented 9 years ago

ok, thanks.

obfischer commented 7 years ago

I am using ANTLR 4.6 and have the same problem. You can reproduce if you try the following

> git clone git@github.com:buschmais/jqa-json-plugin.git
> git checkout antlr-fails-with-npe
> mvn clean install -P IT

To cope the problem I currently have to examine the strack trace and to suppress the NPE caused by ANTLR.

parrt commented 7 years ago

thanks @obfischer !

obfischer commented 6 years ago

Hi @parrt, is there any progress on this issue?

parrt commented 6 years ago

Nope. :( Working on ST4 release.

obfischer commented 6 years ago

I understand. May be the label status:not-fixing could be removed. Indeed I am not sure of its meaning.

parrt commented 6 years ago

Well, i removed though I'm not sure if we can actually change anything per @sharwell above. can you paste the small example that causes issue?

obfischer commented 6 years ago

I will do it on the weekend. Today is time to go to bed...