Bug 252481 - [code assist] NPE in findAllTypes
Summary: [code assist] NPE in findAllTypes
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M3   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-28 15:27 EDT by Olivier Thomann CLA
Modified: 2008-12-09 05:49 EST (History)
4 users (show)

See Also:
philippe_mulet: pmc_approved+


Attachments
Proposed fix (2.43 KB, patch)
2008-10-29 11:48 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2008-10-28 15:27:42 EDT
Using eclipse.buildId=I20081028-0100
java.version=1.6.0_10
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=fr_CA
Command-line arguments:  -os win32 -ws win32 -arch x86 -debug -consolelog -console,

I got this in my .log file while editing a file. Unfortunately no steps to reproduce.
 
java.lang.NullPointerException
at org.eclipse.jdt.internal.codeassist.SelectionEngine.findAllTypes(SelectionEngine.java:733)
at org.eclipse.jdt.internal.codeassist.SelectionEngine.select(SelectionEngine.java:927)
at org.eclipse.jdt.internal.core.Openable.codeSelect(Openable.java:162)
at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:375)
at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:369)
at org.eclipse.jdt.internal.ui.javaeditor.JavaElementHyperlinkDetector.detectHyperlinks(JavaElementHyperlinkDetector.java:67)
at org.eclipse.ui.texteditor.HyperlinkDetectorRegistry$HyperlinkDetectorDelegate.detectHyperlinks(HyperlinkDetectorRegistry.java:80)
at org.eclipse.jface.text.hyperlink.HyperlinkManager.findHyperlinks(HyperlinkManager.java:265)
at org.eclipse.jface.text.hyperlink.HyperlinkManager.mouseMove(HyperlinkManager.java:465)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:199)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3848)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3446)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:333)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:370)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Comment 1 David Audel CLA 2008-10-29 08:51:22 EDT
I found steps to reproduce a similar bug

1) create an empty X.java
2) copy on the following content in X.java
ZZZZZ
3) select ZZZZZ
4) do F3

This exception occurs

java.lang.NullPointerException
	at org.eclipse.jdt.internal.codeassist.SelectionEngine.findAllTypes(SelectionEngine.java:733)
	at org.eclipse.jdt.internal.codeassist.SelectionEngine.select(SelectionEngine.java:927)
	at org.eclipse.jdt.internal.core.Openable.codeSelect(Openable.java:162)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:375)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:369)
	at org.eclipse.jdt.internal.ui.actions.SelectionConverter.codeResolve(SelectionConverter.java:252)
	at org.eclipse.jdt.internal.ui.actions.SelectionConverter$1$CodeResolveRunnable.run(SelectionConverter.java:236)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Comment 2 Jerome Lanneluc CLA 2008-10-29 10:58:06 EDT
We should fix for M3 since this is a regression comparing to M2.
Comment 3 David Audel CLA 2008-10-29 11:48:24 EDT
Created attachment 116431 [details]
Proposed fix

This patch add a null check to avoid the NPE.
Comment 4 Jerome Lanneluc CLA 2008-10-29 11:50:52 EDT
Philippe, ok to put in 3.5M3 since this is an exception, this a regression comparing to M2 and the fix is trivial ?
Comment 5 Philipe Mulet CLA 2008-10-29 11:53:05 EDT
+1 for 3.5M3. Discussed in arch call.
Comment 6 David Audel CLA 2008-10-29 11:57:25 EDT
Released for 3.5M3.

Test added
  ResolveTests#testEmptyCU1()

When i fixed this bug i noticed some issues in SelectionEngine#checkSelection() (see bug 252481)
Comment 7 David Audel CLA 2008-10-29 12:02:32 EDT
The bug reference in my previous comment is incorrect it should be bug 252598
Comment 8 Srikanth Sankaran CLA 2008-12-09 03:06:14 EST
Verified for 3.5M4 using I20081208-1800 build