Bug 223253 - NPE in TypeBinding.getName
Summary: NPE in TypeBinding.getName
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-19 16:49 EDT by Walter Harley CLA
Modified: 2008-03-21 15:12 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Walter Harley CLA 2008-03-19 16:49:45 EDT
I think this is a consequence of the fix for bug 183211.  I am getting the following NPE when typing a static import statement into the editor:

!ENTRY org.eclipse.core.jobs 4 2 2008-03-19 13:40:04.008
!MESSAGE An internal error occurred during: "Requesting Java AST from selection".
!STACK 0
java.lang.NullPointerException
	at java.lang.String.<init>(String.java:176)
	at org.eclipse.jdt.core.dom.TypeBinding.getName(TypeBinding.java:621)
	at org.eclipse.jdt.internal.ui.search.OccurrencesFinder.initialize(OccurrencesFinder.java:88)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.updateOccurrenceAnnotations(JavaEditor.java:3258)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor$7.selectionChanged(JavaEditor.java:3284)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:176)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListenerWithASTManager.java:153)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

To reproduce, create a project with the following two files:

  // p1/X.java:
  package p1;
  interface I { class A {} }
  class C { public static class A {} }
  public class X extends C implements I {}

  // p2/Y.java:
  package p2;

  class Y {}

Now, put the cursor in Y.java on the line before the class declaration, and attempt to type the following:

  import static p1.X.A;

The above NPE happens.  Closing the NPE error message immediately brings another error message to the front, and so forth, so there is no way to exit the editor except by killing the task in Task Manager.

This is a regression: in I20080305, all that would happen is that the static import statement would get a compile error, "type p1.X.A is not visible".
Comment 1 Philipe Mulet CLA 2008-03-20 02:00:08 EDT
This is a regression indeed, but I don't think it is easy to find. So we can fix it during M7 (if unable to tackle it during M6).
Comment 2 Kent Johnson CLA 2008-03-20 10:47:09 EDT
I've removed the patch for bug 183211 and it doesn't fix this problem.

And I was able to reproduce this problem with the build I20080318-0800
Comment 3 Kent Johnson CLA 2008-03-20 11:38:52 EDT
I was able to reproduce this in M4 so its been around for a while now.

Was fine in 3.3.2
Comment 4 Walter Harley CLA 2008-03-20 12:25:55 EDT
I think I see what's happening.  When I try this in I20080304, I'm still getting the NPE, but it is nonfatal, it just gets logged to the error log.  When I tried it in a target workbench launched from my dev workbench synced to HEAD, I got the fatal (i.e. have to kill process with task mgr) problem I described.

I haven't had a chance to the latest build so I don't know whether it will be fatal in that context.  I will give that a try.

I agree that if the problem is just being logged, it is not important to fix by M6.
Comment 5 Walter Harley CLA 2008-03-20 19:54:26 EDT
In 20080319-2000, when I test this in a normal workspace (as opposed to a target workspace launched from PDE), the NPE is logged but does not cause any other problems.

Reducing severity to "normal".
Comment 6 Philipe Mulet CLA 2008-03-20 21:32:07 EDT
Fix is included in latest version of patch for bug 183211.
https://bugs.eclipse.org/bugs/attachment.cgi?id=93065
Comment 7 Philipe Mulet CLA 2008-03-20 21:32:39 EDT
Fixed
Comment 8 Walter Harley CLA 2008-03-21 15:12:50 EDT
Problem is fixed.  Thanks!