Bug 126180 - [1.5][compiler] NPE reporting invalid enclosing type
Summary: [1.5][compiler] NPE reporting invalid enclosing type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-02 09:16 EST by Philipe Mulet CLA
Modified: 2006-02-15 07:48 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2006-02-02 09:16:03 EST
Build 3.2m4

The problem below is causing a NPE to be raised by compiler.

public class X {
	static String foo;

	public static void main(String[] args) {
		C2 c2 = null;
		C3 c3 = null;
		// method access
		m1(c2, c3).c1m1();
		m1(c2, c3).i1m1();
		m1(c2, c3).i2m1();

		// field access
		int ic1 = m1(c2, c3).c1f1;
		int ii1 = m1(c2, c3).i1f1;
		int ii2 = m1(c2, c3).i2f1;
	
		// member type access
		Object oc1 = m1(c2, c3).new C1Member();
		Object oi1 = m1(c2, c3).new I1Member(); 
		Object oi2 = m1(c2, c3).new I2Member();
	}

	public static <T> T m1(T t1, T t2) {
		return null;
	}

	class C1 {
		void c1m1() {}
		int c1f1 = 0;
		class C1Member {}
	}

	interface I1 {
		void i1m1();
		int i1f1 = 1;
		class I1Member {}
	}

	interface I2 {
		void i2m1();
		int i2f1 = 2;
		class I2Member {}
	}

	class C2 extends C1 implements I1, I2 {
		public void i1m1() {
		}
		public void i2m1() {
		}
	}

	class C3 extends C1 implements I1, I2 {
		public void i1m1() {
		}
		public void i2m1() {
		}
	}
}
Comment 1 Philipe Mulet CLA 2006-02-02 09:16:27 EST
!ENTRY org.eclipse.jdt.ui 4 0 2006-02-02 15:16:40.493
!MESSAGE Error in JDT Core during AST creation
!STACK 0
java.lang.NullPointerException
        at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.invalidEnclosingType(ProblemReporter.java:2635)
        at org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.resolveTypeEnclosing(SingleTypeReference.java:63)
        at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.resolveType(QualifiedAllocationExpression.java:226)
        at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:200)
        at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:432)
        at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:179)
        at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:403)
        at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1088)
        at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1137)
        at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:354)
        at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:878)
        at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:506)
        at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:814)
        at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:613)
        at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:584)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
        at org.eclipse.core.runtime.Platform.run(Platform.java:804)
        at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:581)
        at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:504)
        at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.getClipboardData(ClipboardOperationAction.java:394)
        at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.doCutCopyWithImportsOperation(ClipboardOperationAction.java:323)
        at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.internalDoOperation(ClipboardOperationAction.java:279)
        at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction$1.run(ClipboardOperationAction.java:248)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
        at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.run(ClipboardOperationAction.java:246)
        at org.eclipse.jface.action.Action.runWithEvent(Action.java:492)
        at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:117)
        at org.eclipse.core.commands.Command.executeWithChecks(Command.java:384)
        at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:420)
        at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:159)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:466)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:794)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:841)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:563)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:506)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:122)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
        at org.eclipse.swt.widgets.Display.filterEvent(Display.java:978)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:919)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:944)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:929)
        at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:957)
        at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:953)
        at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1267)
        at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3335)
        at org.eclipse.swt.widgets.Control.windowProc(Control.java:3235)
        at org.eclipse.swt.widgets.Display.windowProc(Display.java:3965)
        at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
        at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1730)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2905)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1792)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1756)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:401)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
        at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106)
        at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:109)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:93)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:69)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:374)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169)
        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:324)
        at org.eclipse.core.launcher.Main.invokeFramework(Main.java:338)
        at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
        at org.eclipse.core.launcher.Main.run(Main.java:977)
        at org.eclipse.core.launcher.Main.main(Main.java:952)
Comment 2 Philipe Mulet CLA 2006-02-02 09:17:03 EST
Actually, build ID should read:
Version: 3.2.0
Build id: I20060131-1200
Comment 3 Philipe Mulet CLA 2006-02-02 09:19:53 EST
Reduced testcase:
public class X {
	public static void main(String[] args) {
		C2 c2 = null;
		C3 c3 = null;
		// member type access
		Object oc1 = m1(c2, c3).new C1Member();
	}

	public static <T> T m1(T t1, T t2) {
		return null;
	}

	class C1 {
		class C1Member {}
	}

	interface I1 {
	}

	class C2 extends C1 implements I1 {
	}

	class C3 extends C1 implements I1 {
	}
}
Comment 4 Philipe Mulet CLA 2006-02-02 09:27:09 EST
Even simpler scenario:
public class X {
	public static void main(String[] args) {
		C2 c2 = null;
		C3 c3 = null;
		// member type access
		Object oc1 = m1(c2, c3).new C1Member();
	}

	public static <T> T m1(T t1, T t2) {
		return null;
	}

	class C1 {
	}
	interface I1 {
	}

	class C2 extends C1 implements I1 {
	}

	class C3 extends C1 implements I1 {
	}
}
Comment 5 Philipe Mulet CLA 2006-02-02 09:29:01 EST
This is a consequence of some protection added while reporting some problems to be more resilient with recovered statements.

The protection is incorrectly handling wildcards etc... i.e. types for which the sourceName is null per construction.

Added GenericTypeTest#test892.
Fixed

David - pls check other occurrences.
Comment 6 David Audel CLA 2006-02-02 11:43:21 EST
I updated the other protections in ProblemReporter.
Comment 7 Jerome Lanneluc CLA 2006-02-15 07:48:52 EST
Verified for 3.2 M5 using build I20060215-0010