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.

Bug 73411 - NullPointerException during 'Fix Imports'
Summary: NullPointerException during 'Fix Imports'
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 5.x
Hardware: PC Windows ME/2000
: P2 blocker with 1 vote (vote)
Assignee: Daniel Prusa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-09 09:18 UTC by bmulder_spg
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Message log for the session with the NullPointerException in it. (67.92 KB, text/plain)
2006-03-09 09:34 UTC, bmulder_spg
Details
Correction: previous file by this name is an RTF file. this is a plain textfile. (63.36 KB, text/plain)
2006-03-09 09:37 UTC, bmulder_spg
Details
Log file for the ClassCastException which may be the source of this bug (66.45 KB, text/plain)
2006-03-09 10:33 UTC, bmulder_spg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bmulder_spg 2006-03-09 09:18:28 UTC
I encountered a NullPointerException during 'Fix imports' on an incomplete
(hence non-compiling) java source file with only 'static' members.
Here's the stacktrace:

java.lang.NullPointerException
	at org.netbeans.modules.javacore.parser.MDRParser.getMemberOf(MDRParser.java:2133)
	at
org.netbeans.modules.javacore.parser.MDRParser.processMultiPartId(MDRParser.java:2106)
	at
org.netbeans.modules.javacore.parser.MDRParser.processMultiPartId(MDRParser.java:2103)
	at
org.netbeans.modules.javacore.parser.MDRParser.processASTBody(MDRParser.java:1977)
	at
org.netbeans.modules.javacore.parser.MDRParser.processASTBody(MDRParser.java:1535)
	at org.netbeans.modules.javacore.parser.MDRParser.enterBody(MDRParser.java:208)
	at org.netbeans.modules.javacore.parser.MDRParser.doAttribution(MDRParser.java:175)
	at
org.netbeans.modules.javacore.parser.MDRParser.isVariableAccess(MDRParser.java:1029)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.getElementProxy(MetadataElement.java:633)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.createElement(MetadataElement.java:554)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.initOrCreate(MetadataElement.java:1312)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.FieldImpl.initInitValue(FieldImpl.java:148)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.FieldImpl.getInitialValue(FieldImpl.java:415)
	at org.netbeans.jmi.javamodel.Field$Impl.getInitialValue(Unknown Source)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.FieldImpl.getChildren(FieldImpl.java:64)
	at
org.netbeans.modules.editor.java.JavaFixAllImports.findPotentialClassNames(JavaFixAllImports.java:537)
	at
org.netbeans.modules.editor.java.JavaFixAllImports.findPotentialClassNames(JavaFixAllImports.java:595)
	at
org.netbeans.modules.editor.java.JavaFixAllImports.findPotentialClassNames(JavaFixAllImports.java:649)
	at
org.netbeans.modules.editor.java.JavaFixAllImports.addAllNeededImports(JavaFixAllImports.java:135)
	at
org.netbeans.modules.editor.java.JavaFixAllImports$2.run(JavaFixAllImports.java:81)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:493)
[catch] at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:926)

I'll attach the logfile.
Comment 1 Jan Lahoda 2006-03-09 09:26:10 UTC
=>java/javacore
Comment 2 bmulder_spg 2006-03-09 09:34:41 UTC
Created attachment 29178 [details]
Message log for the session with the NullPointerException in it.
Comment 3 bmulder_spg 2006-03-09 09:37:57 UTC
Created attachment 29179 [details]
Correction: previous file by this name is an RTF file. this is a plain textfile.
Comment 4 bmulder_spg 2006-03-09 10:31:42 UTC
Further investigation showed that the following code block reproduces the error:

public class Test {
    
    public static final int ONE = 1;
    public static final int TWO = 2;
    public static final int THREE = 3;
    public static final int NUMBER_COUNT = new Object[]{ONE,TWO,THREE}.length;
    
    public static Color getColor(){
        return null;
    }
    
}

However leaving out the method results in a DIFFERENT error, which is probably
the cause of this error:

java.lang.ClassCastException: org.netbeans.jmi.javamodel.NewArrayExpression$Impl
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.TypeReferenceImpl.initChildren(TypeReferenceImpl.java:65)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.MultipartIdImpl.initChildren(MultipartIdImpl.java:46)
	at
org.netbeans.modules.javacore.jmiimpl.javamodel.MultipartIdImpl.getTypeArguments(MultipartIdImpl.java:59)
	at org.netbeans.jmi.javamodel.MultipartId$Impl.getTypeArguments(Unknown Source)
	at
org.netbeans.modules.editor.java.JavaFixAllImports.findPotentialClassNames(JavaFixAllImports.java:524)
	at
org.netbeans.modules.editor.java.JavaFixAllImports.findPotentialClassNames(JavaFixAllImports.java:595)
	at
org.netbeans.modules.editor.java.JavaFixAllImports.findPotentialClassNames(JavaFixAllImports.java:595)
	at
org.netbeans.modules.editor.java.JavaFixAllImports.findPotentialClassNames(JavaFixAllImports.java:649)
	at
org.netbeans.modules.editor.java.JavaFixAllImports.addAllNeededImports(JavaFixAllImports.java:135)
	at
org.netbeans.modules.editor.java.JavaFixAllImports$2.run(JavaFixAllImports.java:81)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:493)
[catch] at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:926)

Again, I've attached the resultant message.log for more information.
Comment 5 bmulder_spg 2006-03-09 10:33:58 UTC
Created attachment 29180 [details]
Log file for the ClassCastException which may be the source of this bug
Comment 6 Jiri Prox 2006-03-09 10:59:18 UTC
reproducible
Comment 7 Jan Becicka 2006-03-31 15:03:20 UTC
Dan is fix imports expert :)
Comment 8 Daniel Prusa 2006-05-09 15:04:20 UTC
Fixed in trunk.

/cvs/java/javacore/src/org/netbeans/modules/javacore/parser/MDRParser.java
new revision: 1.99; previous revision: 1.98
Comment 9 Daniel Prusa 2006-05-10 14:18:34 UTC
Fix merged into release55 branch.

/cvs/java/javacore/src/org/netbeans/modules/javacore/parser/MDRParser.java
new revision: 1.85.6.4.2.2; previous revision: 1.85.6.4.2.1
Comment 10 Quality Engineering 2007-09-20 09:43:19 UTC
Reorganization of java component