Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 95481

Summary: [1.5] NPE in TypeVariableBinding.checkBounds
Product: [Eclipse Project] JDT Reporter: Kory Markevich <vulcannis>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: philippe_mulet
Version: 3.1   
Target Milestone: 3.1 RC2   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Kory Markevich CLA 2005-05-16 18:19:35 EDT
Found in 3.1M7.  Using the following code, each class in it's own source file:

public class Test< T extends Test< T, B, C >, B extends Key< T, B, C >, C
extends State > { }

public class Key< T extends Test< T, K, S >, K extends Key< T, K, S >, S extends
State > { }

public class State { }

Attempting to Open Declaration or Source Hover over the types inside the type
restrictions results in an NPE.  e.g., put the cursor in "State" of the fragment
"S extends State" of Test.java, and hit F3.  The following NPE should occur:

Error 2005-05-16 15:12:41.25 java.lang.NullPointerException
java.lang.NullPointerException
	at
org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding.boundCheck(TypeVariableBinding.java:73)
	at
org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.checkBounds(ParameterizedSingleTypeReference.java:41)
	at
org.eclipse.jdt.internal.compiler.ast.TypeParameter.checkBounds(TypeParameter.java:36)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.checkParameterizedTypeBounds(ClassScope.java:680)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:867)
	at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:254)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:249)
	at org.eclipse.jdt.internal.codeassist.impl.Engine.accept(Engine.java:84)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:131)
	at
org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:178)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2489)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:2235)
	at
org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.internalResolveType(ParameterizedSingleTypeReference.java:101)
	at
org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.resolveType(ParameterizedSingleTypeReference.java:214)
	at
org.eclipse.jdt.internal.compiler.lookup.Scope.connectTypeVariables(Scope.java:402)
	at
org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:861)
	at
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:254)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:249)
	at
org.eclipse.jdt.internal.codeassist.SelectionEngine.select(SelectionEngine.java:646)
	at org.eclipse.jdt.internal.core.Openable.codeSelect(Openable.java:165)
	at
org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:314)
	at
org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:308)
	at
org.eclipse.jdt.internal.ui.actions.SelectionConverter.codeResolve(SelectionConverter.java:219)
	at
org.eclipse.jdt.internal.ui.actions.SelectionConverter.codeResolve(SelectionConverter.java:153)
	at
org.eclipse.jdt.internal.ui.actions.SelectionConverter.codeResolve(SelectionConverter.java:162)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:128)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:226)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:198)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:996)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:182)
	at
org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:108)
	at org.eclipse.core.commands.Command.execute(Command.java:311)
	at
org.eclipse.core.commands.ParameterizedCommand.execute(ParameterizedCommand.java:396)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:452)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:722)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:766)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:543)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:486)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:110)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:781)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:841)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:866)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:851)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:879)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:875)
	at org.eclipse.swt.widgets.Widget.wmKeyDown(Widget.java:1467)
	at org.eclipse.swt.widgets.Control.WM_KEYDOWN(Control.java:3347)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3067)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3513)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1650)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2552)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1601)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1565)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:315)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
	at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:230)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:371)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:160)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:330)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:274)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)

If the Key and Test classes share the same source file, then this error doesn't
occur.
Comment 1 Kory Markevich CLA 2005-05-21 00:06:31 EDT
Just an update: content assist, content information, quick fix (but not assist),
and some refactorings (sometimes just display the refactoring menu) also trigger
this.  I have this bug happening in a large project and it pretty much reduces
Eclipse to a basic text editor.
Comment 2 Kent Johnson CLA 2005-05-26 16:59:50 EDT
Reduced testcase with 2 files:

public class Test<
	K extends Key<T, K>,
	T extends Test<K, T>> {
}

public class Key<
	TT extends Test<KK, TT>,
	KK extends Key<TT, KK>> {
}
Comment 3 Kent Johnson CLA 2005-05-30 11:09:34 EDT
Fixed.

Hover over any of the types/variables.
Comment 4 Kent Johnson CLA 2005-05-30 11:42:38 EDT
Added ResolveTest_1_5 test0097
Comment 5 Olivier Thomann CLA 2005-06-06 17:05:32 EDT
Verified using N20050606-0010 + JDT/Core HEAD
Comment 6 Maxime Daniel CLA 2005-06-10 09:25:43 EDT
Verified for 3.1 RC2 using build I20050610-0010
Comment 7 Frederic Fusier CLA 2005-06-10 10:26:55 EDT
close