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.
NetBeans 5.0 Beta 2 on Windows XP I had been using NetBeans for some time with only an occasional NullPointerException but I have been working only with Java files. I recently tried to port some old C++ code to Java and I was overwhelmed with NullPointer exceptions, which prevented using the editor to fix the numerous porting issues. Note that the compiler does not choke on the project, only the IDE. I am attaching the zip of a simple project. The code is primitive and has too many errors to compile successfully, but does illustrate the NullPointerException problem well. I tried creating a simpler example, but could not create one that was so effective at showing the problem. To reproduce the problem, unzip the attached project folder and open the project in NetBeans 5 Beta 2 using JDK 6. (It will also faile with JDK 5.) Expand the Project until the source file names are visible. Single click on Parser.java Look in the Navigator window - it appears to be hung on "Scanning in progress..." Double click on Parser.java - NullPointer and file opens. Click anywhere in file to set the keyboard focus - NullPointer. Click again in same spot or different spot - NullPointer. Right-click on the Parser.java file name on the editor tab - NullPointer. You also can't simply keep the Exception window open to continue working because the keyboard focus keeps shifting back to the Exception window. You are effectively blocked from editing the file to fix its problems! The NullPointers could be related to the hung Navigator, but closing the Navigator window doesn't prevent the NullPointer exceptions. A typical stack trace of an exception is: java.lang.NullPointerException at org.netbeans.modules.javacore.parser.MDRParser.processAST(MDRParser. java:434) at org.netbeans.modules.javacore.parser.MDRParser.processAST(MDRParser. java:369) at org.netbeans.modules.javacore.parser.MDRParser.processAST(MDRParser. java:331) at org.netbeans.modules.javacore.parser.MDRParser.processAST(MDRParser. java:309) at org.netbeans.modules.javacore.parser.MDRParser.enterMembers(MDRParser. java:239) at org.netbeans.modules.javacore.jmiimpl.javamodel.ResourceImpl. directUpdate(ResourceImpl.java:733) at org.netbeans.modules.javacore.jmiimpl.javamodel.ResourceImpl. checkUpToDate(ResourceImpl.java:644) at org.netbeans.modules.javacore.jmiimpl.javamodel.ResourceImpl. checkUpToDate(ResourceImpl.java:587) at org.netbeans.modules.javacore.jmiimpl.javamodel.ResourceImpl. initResource(ResourceImpl.java:430) at org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement. initCheck(MetadataElement.java:134) at org.netbeans.modules.javacore.jmiimpl.javamodel.SemiPersistentElement. getElementInfo(SemiPersistentElement.java:185) at org.netbeans.modules.javacore.jmiimpl.javamodel.SemiPersistentElement. getInternalForm(SemiPersistentElement.java:834) at org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement. getASTree(MetadataElement.java:515) at org.netbeans.modules.javacore.jmiimpl.javamodel.SemiPersistentElement. getParser(SemiPersistentElement.java:829) at org.netbeans.modules.javacore.jmiimpl.javamodel.ResourceImpl. getFeaturePosition(ResourceImpl.java:460) at org.netbeans.modules.javacore.jmiimpl.javamodel.FeatureImpl. getPosition(FeatureImpl.java:270) at org.netbeans.modules.javacore.JMManager.getElementPosition(JMManager. java:725) at org.netbeans.modules.javacore.JMManager.getElementPosition(JMManager. java:711) at org.netbeans.modules.java.JavaEditor$JavaEditorComponent. findElement(JavaEditor.java:1331) at org.netbeans.modules.java.JavaEditor$JavaEditorComponent. createNode(JavaEditor.java:1279) at org.netbeans.modules.java.JavaEditor$JavaEditorComponent. access$900(JavaEditor.java:1199) at org.netbeans.modules.java.JavaEditor$12.run(JavaEditor.java:1251) at org.openide.util.Mutex.readAccess(Mutex.java:195) at org.netbeans.modules.java.JavaEditor$11.run(JavaEditor.java:1249) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:471) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor. java:904)
Created attachment 27211 [details] zipped project folder to reproduce NullPointer issue
Reassigning to javacore, please evaluate. Thanks.
Problem occurs when there are semicolons after enum and there is syntax error in the source. Simplier source which allows to reproduce the bug: package javaapplication1; enum A {A1, A2}; enum B {B1, B2}; public class Main { syntaxerror; } We work on fix. For the time being, you can remove semicolons after enums. (They doesn't make sense and without them you will be able to continue in your work.) Anyway, thanks for very good bug report, your attached project was really helpful for analysing the problem.
Checking in org/netbeans/modules/javacore/parser/ASTRepairer.java; /cvs/java/javacore/src/org/netbeans/modules/javacore/parser/ASTRepairer.java,v <-- ASTRepairer.java new revision: 1.10; previous revision: 1.9 done
Reorganization of java component