Bug 221215 - [assist] NPE in problem reporter
Summary: [assist] NPE in problem reporter
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: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-03 15:14 EST by Olivier Thomann CLA
Modified: 2008-03-25 13:17 EDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (5.39 KB, patch)
2008-03-05 04:45 EST, Philipe Mulet 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-03-03 15:14:47 EST
Using I22080227-1100, I got this stack trace in the .log file.
No steps to reproduce so far. Might be related to exposing missing types.

java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.invalidField(ProblemReporter.java:3059)
	at org.eclipse.jdt.internal.codeassist.select.SelectionOnQualifiedNameReference.resolveType(SelectionOnQualifiedNameReference.java:74)
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:186)
	at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:101)
	at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:101)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:444)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:191)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:403)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1096)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1175)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1014)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1184)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:534)
	at org.eclipse.jdt.internal.codeassist.SelectionEngine.select(SelectionEngine.java:699)
	at org.eclipse.jdt.internal.core.Openable.codeSelect(Openable.java:156)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:354)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:348)
	at org.eclipse.jdt.internal.ui.actions.SelectionConverter.codeResolve(SelectionConverter.java:252)
	at org.eclipse.jdt.internal.ui.actions.SelectionConverter.codeResolve(SelectionConverter.java:143)
	at org.eclipse.jdt.internal.ui.actions.SelectionConverter.codeResolve(SelectionConverter.java:128)
	at org.eclipse.mylyn.internal.java.ui.JavaEditingMonitor.handleWorkbenchPartSelection(JavaEditingMonitor.java:87)
	at org.eclipse.mylyn.monitor.ui.AbstractUserInteractionMonitor.selectionChanged(AbstractUserInteractionMonitor.java:66)
	at org.eclipse.ui.internal.AbstractSelectionService.firePostSelection(AbstractSelectionService.java:179)
	at org.eclipse.ui.internal.AbstractSelectionService$2.selectionChanged(AbstractSelectionService.java:71)
	at org.eclipse.jface.text.TextViewer.firePostSelectionChanged(TextViewer.java:2582)
	at org.eclipse.jface.text.TextViewer.firePostSelectionChanged(TextViewer.java:2534)
	at org.eclipse.jface.text.TextViewer$5.run(TextViewer.java:2513)
	at org.eclipse.swt.widgets.Display.runTimer(Display.java:3835)
	at org.eclipse.swt.widgets.Display.messageProc(Display.java:3041)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2333)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3369)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2402)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2366)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2232)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:476)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:471)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:77)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:362)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175)
	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 Benno Baumgartner CLA 2008-03-04 05:43:09 EST
I've found steps.

Given:
package test;
public class Event {
	public int x;
	
	public void handle(Event e) {
		e.x. e.|
	}
}
1. Replace '|' with cursor
2. Ctrl-Space
Is:
 NPE is thrown
Comment 2 Philipe Mulet CLA 2008-03-04 06:38:30 EST
Olivier's trace looks like a codeselect operation.
Strangely enough the line number is not telling much (see line >> below)

  if ((field.declaringClass.tagBits & TagBits.HasMissingType) != 0) {
    this.handle(
      IProblem.UndefinedType,
      new String[] {new String(field.declaringClass.readableName())},
      new String[] {new String(field.declaringClass.shortReadableName())},
      nameRef.sourceStart,
      nameRef.sourceEnd);
>>  return;				
  }

			
Comment 3 Philipe Mulet CLA 2008-03-04 06:42:04 EST
Actually, Benno, your testcase is really good.

public class Event {
        public int x;
        public void handle(Event e) {
                e.x. e.foo();
        }
}

Selecting on 'e' (the 2nd occurrence acting as receiver for #foo()) reproduces exactly Olivier's trace.
Comment 4 Benno Baumgartner CLA 2008-03-04 07:51:50 EST
(In reply to comment #3)
> Actually, Benno, your testcase is really good.

Thank you:-) Actually this can happen easily: I've typed '.' instead of ',' by mistake.
Comment 5 Philipe Mulet CLA 2008-03-04 10:00:19 EST
Added CompletionTests#testInvalidField1-2
Added ResolveTests#testInvalidField1-2
Comment 6 Philipe Mulet CLA 2008-03-05 04:45:25 EST
Created attachment 91624 [details]
Proposed patch
Comment 7 Philipe Mulet CLA 2008-03-05 06:56:51 EST
Released for 3.4M6
Fixed
Comment 8 Frederic Fusier CLA 2008-03-25 13:17:28 EDT
Verified for 3.4M6 using I20080324-1300.