Bug 10592

Summary: ast: NPE in SingleVariableDeclaration::resolveBinding
Product: [Eclipse Project] JDT Reporter: Adam Kiezun <akiezun>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.0 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Adam Kiezun CLA 2002-03-01 11:40:23 EST
package p;
class A{
	native void m(int i);
}

i get an NPE when i call resolveBinding on the declaration of 'i'
(the CompilationUnit node was created with resolveBindings == true, 
if that makes a difference)

java.lang.NullPointerException
	at org.eclipse.jdt.core.dom.DefaultBindingResolver.resolveVariable
(DefaultBindingResolver.java:297)
	at org.eclipse.jdt.core.dom.VariableDeclaration.resolveBinding
(VariableDeclaration.java:92)
Comment 1 Olivier Thomann CLA 2002-03-01 11:42:56 EST
In this case, I guess you expect null to be returned.
Comment 2 Adam Kiezun CLA 2002-03-01 11:45:48 EST
when creating regression tests for it - please include also this one:
abstract class A{
	abstract void m(int i);
}
Comment 3 Adam Kiezun CLA 2002-03-01 12:01:02 EST
this one is meybe related 
(resolveBinding on the SimpleName 'k' inside the qualified name 'j.k'):

class A{
	int k;
	static class j{
		static int k;
	}
	void m(){
		int y= 0;
		j.k= 0;
	}
}	

stack trace is different:
at org.eclipse.jdt.core.dom.DefaultBindingResolver.resolveNameForNameReference
(DefaultBindingResolver.java:222) 
at  org.eclipse.jdt.core.dom.DefaultBindingResolver.resolveName
(DefaultBindingResolver.java:97)
at org.eclipse.jdt.core.dom.Name.resolveBinding(Name.java:75)
Comment 4 Adam Kiezun CLA 2002-03-01 12:02:35 EST
another test case for your collection :)

(resolveBinding on the declaration of 'i')
interface A{
	 void m(int i, int j);
}
Comment 5 Olivier Thomann CLA 2002-03-01 15:11:00 EST
I forgot to connect the name inside a SingleVariableDeclaration. So it was 
impossible to retrieve the compiler node corresponding to a method parameter.
Fixed and released in HEAD.
Comment 6 Olivier Thomann CLA 2002-03-01 15:11:51 EST
Fixed.