Bug 358762 - NPE in JDT compiler
Summary: NPE in JDT compiler
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.8 M3   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-23 14:45 EDT by Vincent Privat CLA
Modified: 2011-10-24 09:30 EDT (History)
2 users (show)

See Also:


Attachments
Errors log file (179.01 KB, application/octet-stream)
2011-09-23 14:46 EDT, Vincent Privat CLA
no flags Details
Proposed fix (970 bytes, patch)
2011-09-23 14:59 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Privat CLA 2011-09-23 14:45:54 EDT
Build Identifier: M20110909-1335

I've just got an NPE with the attached stack trace, while editing a simple Java class in 1.6 mode.

I have updated to 3.7.1 few hours ago. My config is the following:
- Eclipse IDE: 3.7.1 running with Java 7 x64 on Windows 7 SP1 x64
- Java Project: configured with jdk6u27 x64

The NPE is here:
java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.isRecursive(ConstructorDeclaration.java:429)


Reproducible: Didn't try
Comment 1 Vincent Privat CLA 2011-09-23 14:46:43 EDT
Created attachment 203929 [details]
Errors log file
Comment 2 Olivier Thomann CLA 2011-09-23 14:58:44 EDT
I can see how this is possible. Now, I could not find a test case to reproduce
this issue.

The targetConstructor can be set to null on line 417. And we never check for
null.
I propose to insert:
if (targetConstructor == null) return false;

This must be a case where there is already an error in the code. I'll attach a
patch shortly.
Comment 3 Olivier Thomann CLA 2011-09-23 14:59:23 EDT
Created attachment 203931 [details]
Proposed fix

A regression test must be found for this problem.
Comment 4 Olivier Thomann CLA 2011-09-23 15:00:23 EDT
Vincent, if you have a chance to describe in what circumstances this is failing, it would be helpful to write a regression test.
Comment 5 Ayushman Jain CLA 2011-09-23 15:05:54 EDT
(In reply to comment #0)
> Build Identifier: M20110909-1335
> 
> I've just got an NPE with the attached stack trace, while editing a simple Java

Vincent, if its a simple Java class, can you please attach it (or a class that mimics it?) Thanks!
Comment 6 Vincent Privat CLA 2011-09-23 15:10:22 EDT
In the log file, you can see the source of the class generating this issue
(OsmImporter).

The compiler errors are the following:
- this statement declares a static final object with an unhlandled exception
from its constructor:
public static final MimeType OSM_XML_MIME_TYPE = new
MimeType("application/x-osm+xml");

- this statement is an incomplete constructor (the one I was writing when the
exception happened):
    public OsmImporter(ExtensionFileFilter filter) {
        this(filter, );
    }

And, that's all. Once this error occurs, it looks like there's a whole bunch of
recursal exceptions on each operator action inside this file (mouse over a
underlined error, click on the error marker, etc.)
Comment 7 Srikanth Sankaran CLA 2011-10-12 04:36:03 EDT
I could not still reproduce the problem with the scenario described in
comment 6, however the patch from comment# 3 looks good and has been
released into master for 3.8 M3.

Commit id: fcd23c7f31f72a5138ea1cad062c9d8a4a84f1dc.
Comment 8 Ayushman Jain CLA 2011-10-24 09:30:17 EDT
Verified for 3.8M3 via code inspection.