Bug 98488 - NPE while computing a key for a paramterized type binding
Summary: NPE while computing a key for a paramterized type binding
Status: CLOSED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-06 06:47 EDT by Dirk Baeumer CLA
Modified: 2005-06-10 11:54 EDT (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 Dirk Baeumer CLA 2005-06-06 06:49:15 EDT
RC1

- toString of the type binding in question returns

public interface Set<Entry<K,V>>
	extends NULL TYPENULL SUPERINTERFACESNULL FIELDSNULL METHODS

- toString of the ParameterizedTypeBinding receiving computeUniqueKey(boolean)

public static interface Entry<K,V>
	extends NULL TYPENULL SUPERINTERFACESNULL FIELDSNULL METHODS


- the NPE happens since enclosingType() returns null

Thread [ModalContext] (Suspended (exception NullPointerException))
	ParameterizedTypeBinding.computeUniqueKey(boolean) line: 179
	ParameterizedTypeBinding.computeUniqueKey(boolean) line: 202
	ParameterizedTypeBinding(Binding).computeUniqueKey() line: 45
	TypeBinding.getKey() line: 453
	InferTypeArgumentsTCModel.createTType(ITypeBinding) line: 294
	InferTypeArgumentsTCModel.makeParameterizedTypeVariable(ITypeBinding) line: 406
	InferTypeArgumentsConstraintCreator.doVisitMethodInvocationReturnType(ASTNode,
IMethodBinding, Expression, Map) line: 473
	InferTypeArgumentsConstraintCreator.endVisit(MethodInvocation) line: 413
	MethodInvocation.accept0(ASTVisitor) line: 246
	MethodInvocation(ASTNode).accept(ASTVisitor) line: 2450
	MethodInvocation(ASTNode).acceptChild(ASTVisitor, ASTNode) line: 2497
	MethodInvocation.accept0(ASTVisitor) line: 239
	MethodInvocation(ASTNode).accept(ASTVisitor) line: 2450
	VariableDeclarationFragment(ASTNode).acceptChild(ASTVisitor, ASTNode) line: 2497
	VariableDeclarationFragment.accept0(ASTVisitor) line: 224
	VariableDeclarationFragment(ASTNode).accept(ASTVisitor) line: 2450
	VariableDeclarationStatement(ASTNode).acceptChildren(ASTVisitor,
ASTNode$NodeList) line: 2520
	VariableDeclarationStatement.accept0(ASTVisitor) line: 272
	VariableDeclarationStatement(ASTNode).accept(ASTVisitor) line: 2450
	Block(ASTNode).acceptChildren(ASTVisitor, ASTNode$NodeList) line: 2520
	Block.accept0(ASTVisitor) line: 135
	Block(ASTNode).accept(ASTVisitor) line: 2450
	MethodDeclaration(ASTNode).acceptChild(ASTVisitor, ASTNode) line: 2497
	MethodDeclaration.accept0(ASTVisitor) line: 501
	MethodDeclaration(ASTNode).accept(ASTVisitor) line: 2450
	TypeDeclaration(ASTNode).acceptChildren(ASTVisitor, ASTNode$NodeList) line: 2520
	TypeDeclaration.accept0(ASTVisitor) line: 483
	TypeDeclaration(ASTNode).accept(ASTVisitor) line: 2450
	CompilationUnit(ASTNode).acceptChildren(ASTVisitor, ASTNode$NodeList) line: 2520
	CompilationUnit.accept0(ASTVisitor) line: 299
	CompilationUnit(ASTNode).accept(ASTVisitor) line: 2450
	InferTypeArgumentsRefactoring$2.run() line: 183
	InternalPlatform.run(ISafeRunnable) line: 1038
	Platform.run(ISafeRunnable) line: 775
	InferTypeArgumentsRefactoring$1.acceptAST(ICompilationUnit, CompilationUnit)
line: 181
	CompilationUnitResolver.resolve(ICompilationUnit[], String[], ASTRequestor,
int, Map, WorkingCopyOwner) line: 691
	CompilationUnitResolver.resolve(ICompilationUnit[], String[], ASTRequestor,
int, Map, IJavaProject, WorkingCopyOwner, IProgressMonitor) line: 455
	ASTParser.createASTs(ICompilationUnit[], String[], ASTRequestor,
IProgressMonitor) line: 652
	InferTypeArgumentsRefactoring.checkFinalConditions(IProgressMonitor) line: 176
	CheckConditionsOperation.run(IProgressMonitor) line: 84
	CreateChangeOperation.run(IProgressMonitor) line: 114
	Workspace.run(IWorkspaceRunnable, ISchedulingRule, int, IProgressMonitor) line:
1719
	WorkbenchRunnableAdapter.run(IProgressMonitor) line: 86
	ModalContext$ModalContextThread.run() line: 113
Comment 1 Philipe Mulet CLA 2005-06-06 07:26:10 EDT
Hopefully these should be resolved along with fix for bug 97108.
Pls verify
Comment 2 Jerome Lanneluc CLA 2005-06-06 09:08:07 EDT
any steps to reproduce ?
Comment 3 Dirk Baeumer CLA 2005-06-06 11:24:46 EDT
I ran Infer type arguments on an older version of jdt.core. I can rerun it if
you want to debug it or I can zip up the sources.
Comment 4 Philipe Mulet CLA 2005-06-07 11:55:21 EDT
+1 for RC2
Comment 5 Jerome Lanneluc CLA 2005-06-07 12:48:27 EDT
Could not find a better test case than Infer Generic Type Arguments on the whole
project org.eclipse.jdt.core v_560.

Fix (by Philippe) is in LookupEnvironment#getTypeFromTypeSignature(...)
Comment 6 Olivier Thomann CLA 2005-06-07 14:16:47 EDT
Verified in N20050606-0010 + JDT/Core HEAD
Comment 7 Markus Keller CLA 2005-06-07 14:17:51 EDT
Reopening. To reproduce with jdt/core and ui from HEAD, run "Infer Generic Type
Arguments" on this class:

import java.util.*;
abstract class MyMap implements Map {
	public Set entrySet() {
		return toHashMap().entrySet();
	}
	private HashMap toHashMap() {
		return null;
	}
}

The ASTView seems to follow another code path:
- set the caret into the invocation of entrySet()
- expand > method binding: HashMap.entrySet()
Now, the exception looks a bit different:

Error 2005-06-07 20:15:31.370 java.lang.NullPointerException
java.lang.NullPointerException
	at
org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.genericTypeSignature(ParameterizedTypeBinding.java:307)
	at
org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.genericTypeSignature(ParameterizedTypeBinding.java:318)
	at
org.eclipse.jdt.internal.compiler.lookup.MethodBinding.genericSignature(MethodBinding.java:374)
	at
org.eclipse.jdt.internal.compiler.lookup.MethodBinding.computeUniqueKey(MethodBinding.java:321)
	at
org.eclipse.jdt.internal.compiler.lookup.MethodBinding.computeUniqueKey(MethodBinding.java:310)
	at
org.eclipse.jdt.internal.compiler.lookup.Binding.computeUniqueKey(Binding.java:45)
	at org.eclipse.jdt.core.dom.MethodBinding.getKey(MethodBinding.java:267)
	at org.eclipse.jdt.astview.views.Binding.getChildren(Binding.java:75)
	at
org.eclipse.jdt.astview.views.ASTViewContentProvider.getChildren(ASTViewContentProvider.java:92)
	at
org.eclipse.jdt.astview.views.ASTViewContentProvider.hasChildren(ASTViewContentProvider.java:230)
	at
org.eclipse.jface.viewers.AbstractTreeViewer.isExpandable(AbstractTreeViewer.java:1378)
	at
org.eclipse.jface.viewers.AbstractTreeViewer.updatePlus(AbstractTreeViewer.java:1840)
	at
org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem(AbstractTreeViewer.java:536)
	at org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractTreeViewer.java:514)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at
org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:494)
	at
org.eclipse.jface.viewers.AbstractTreeViewer.handleTreeExpand(AbstractTreeViewer.java:948)
	at
org.eclipse.jface.viewers.AbstractTreeViewer$4.treeExpanded(AbstractTreeViewer.java:959)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:179)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:844)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:868)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:853)
	at org.eclipse.swt.widgets.Tree.wmNotifyChild(Tree.java:3703)
	at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:3567)
	at org.eclipse.swt.widgets.Composite.WM_NOTIFY(Composite.java:1035)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3088)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3557)
	at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:1577)
	at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java:219)
	at org.eclipse.swt.widgets.Tree.WM_LBUTTONDOWN(Tree.java:2814)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3070)
	at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:2390)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3557)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1653)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2564)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1717)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1681)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:366)
	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:226)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:375)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:162)
	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:585)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
	at org.eclipse.core.launcher.Main.run(Main.java:973)
	at org.eclipse.core.launcher.Main.main(Main.java:948)
Comment 8 Jerome Lanneluc CLA 2005-06-07 17:40:21 EDT
Both test cases (refactoring and using the AST view) work for me with
org.eclipse.jdt.core HEAD. Are you certain you patched correctly ?
Comment 9 Markus Keller CLA 2005-06-08 05:58:27 EDT
Oops, sorry about that. I was tricked by the synchronize view and did not update
LookupEnvironment.
Comment 10 Markus Keller CLA 2005-06-08 05:59:44 EDT
Verified (again) in N20050608-0010.
Comment 11 Jerome Lanneluc CLA 2005-06-09 06:38:20 EDT
Actually you gave us a smaller test case. Thanks !
Added regression test ASTConverter15Test#test189()
Comment 12 Frederic Fusier CLA 2005-06-10 11:54:13 EDT
Verified for 3.1 RC2 using build I20050610-0010
Note that it works with RC1