This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
After the update of jython-parser, I encounter an error when parsing some code. Step to reproduce: 1. Update to have this patch: http://hg.netbeans.org/main/contrib/rev/7268510f9338 2. Start typing a list comprehension, eg: a = [c for c in "hello"] 3. The bug should appear once you typed [c for c i] Netbeans version: Product Version: NetBeans IDE Dev (Build 20150527-e8112fc19595) Java: 1.7.0_79; OpenJDK 64-Bit Server VM 24.79-b02 Runtime: OpenJDK Runtime Environment 1.7.0_79-b14 System: Linux version 3.16.7-21-desktop running on amd64; UTF-8; fr_FR (nb)
Created attachment 153909 [details] NullPointerException stacktrace
I think I was able to figure out what the problem was. The exception is raised in PythonParser#reportError at line 308 when calling super.reportError. In the parent class, reportError just calls BaseRecognizer#reportError (The code is here: https://github.com/antlr/antlr3/blob/master/runtime/Java/src/main/java/org/antlr/runtime/BaseRecognizer.java#L176). It crashes at line 251 (https://github.com/antlr/antlr3/blob/master/runtime/Java/src/main/java/org/antlr/runtime/BaseRecognizer.java#L251) when trying to access to the tokenNames array. It needs an array of token names to work properly. By default, BaseRecognizer#getTokenNames returns null (See https://github.com/antlr/antlr3/blob/master/runtime/Java/src/main/java/org/antlr/runtime/BaseRecognizer.java#L758). We create a new BaseRecognizer to avoid a StackOverflow with the default getTokenNames method. Hence the NullPointerException. My patch simply overrides getTokenNames to return the array of token names from the previous BaseRecognizer. Since the BaseRecognizer#reportError relies on its parameter to work (See: https://github.com/antlr/antlr3/blob/master/runtime/Java/src/main/java/org/antlr/runtime/BaseRecognizer.java#L17), I think we can assume that my patch does the job correctly. The patch is available here: https://bitbucket.org/Jenselme/nb-contrib/commits/branch/bz252630-nullptrexception-after-update-jython_parser-2.7 Review appreciated.
Fixed in http://hg.netbeans.org/main/contrib/rev/0bf82b105206